Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HandlerStack.php

function HandlerStack::create

Creates a default handler stack that can be used by clients.

The returned handler will wrap the provided handler or use the most appropriate default handler for your system. The returned HandlerStack has support for cookies, redirects, HTTP error exceptions, and preparing a body before sending.

The returned handler stack can be passed to a client in the "handler" option.

Parameters

(callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no: handler is provided, the best handler for your system will be utilized.

2 calls to HandlerStack::create()
Client::__construct in vendor/guzzlehttp/guzzle/src/Client.php
Clients accept an array of constructor parameters.
MockHandler::createWithMiddleware in vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php
Creates a new MockHandler that uses the default handler stack list of middlewares.

File

vendor/guzzlehttp/guzzle/src/HandlerStack.php, line 47

Class

HandlerStack
Creates a composed Guzzle handler function by stacking middlewares on top of an HTTP handler function.

Namespace

GuzzleHttp

Code

public static function create(?callable $handler = null) : self {
    $stack = new self($handler ?: Utils::chooseHandler());
    $stack->push(Middleware::httpErrors(), 'http_errors');
    $stack->push(Middleware::redirect(), 'allow_redirects');
    $stack->push(Middleware::cookies(), 'cookies');
    $stack->push(Middleware::prepareBody(), 'prepare_body');
    return $stack;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal