Documentation

RequestFactory
in package
implements RequestFactoryInterface

Default HTTP request factory used to create the default {@see Request} and {@see EntityEnclosingRequest} objects.

Interfaces, Classes and Traits

RequestFactoryInterface
Request factory used to create HTTP requests

Table of Contents

$entityEnclosingRequestClass  : string
$instance  : RequestFactory
$methods  : array<string|int, mixed>
$requestClass  : string
__construct()  : mixed
applyOptions()  : mixed
Apply an associative array of options to the request
cloneRequestWithMethod()  : RequestInterface
Clone a request while changing the method. Emulates the behavior of {@see Guzzle\Http\Message\Request::clone}, but can change the HTTP method.
create()  : RequestInterface
Create a new request based on the HTTP method
fromMessage()  : RequestInterface
Create a new request based on an HTTP message
fromParts()  : RequestInterface
Create a request from URL parts as returned from parse_url()
getInstance()  : RequestFactory
Get a cached instance of the default request factory
visit_allow_redirects()  : mixed
visit_auth()  : mixed
visit_body()  : mixed
visit_cert()  : mixed
visit_connect_timeout()  : mixed
visit_cookies()  : mixed
visit_debug()  : mixed
visit_events()  : mixed
visit_exceptions()  : mixed
visit_headers()  : mixed
visit_params()  : mixed
visit_plugins()  : mixed
visit_proxy()  : mixed
visit_query()  : mixed
visit_save_to()  : mixed
visit_ssl_key()  : mixed
visit_timeout()  : mixed
visit_verify()  : mixed

Properties

$entityEnclosingRequestClass

protected string $entityEnclosingRequestClass = 'Guzzle\Http\Message\EntityEnclosingRequest'

Class to instantiate for requests with a body

$methods

protected array<string|int, mixed> $methods

Hash of methods available to the class (provides fast isset() lookups)

$requestClass

protected string $requestClass = 'Guzzle\Http\Message\Request'

Class to instantiate for requests with no body

Methods

__construct()

public __construct() : mixed
Return values
mixed

applyOptions()

Apply an associative array of options to the request

public applyOptions(RequestInterface $request[, array<string|int, mixed> $options = array() ][, mixed $flags = self::OPTIONS_NONE ]) : mixed
Parameters
$request : RequestInterface

Request to update

$options : array<string|int, mixed> = array()

Options to use with the request. Available options are: "headers": Associative array of headers "query": Associative array of query string values to add to the request "body": Body of a request, including an EntityBody, string, or array when sending POST requests. "auth": Array of HTTP authentication parameters to use with the request. The array must contain the username in index [0], the password in index [2], and can optionally contain the authentication type in index [3]. The authentication types are: "Basic", "Digest", "NTLM", "Any" (defaults to "Basic"). "cookies": Associative array of cookies "allow_redirects": Set to false to disable redirects "save_to": String, fopen resource, or EntityBody object used to store the body of the response "events": Associative array mapping event names to a closure or array of (priority, closure) "plugins": Array of plugins to add to the request "exceptions": Set to false to disable throwing exceptions on an HTTP level error (e.g. 404, 500, etc) "params": Set custom request data parameters on a request. (Note: these are not query string parameters) "timeout": Float describing the timeout of the request in seconds "connect_timeout": Float describing the number of seconds to wait while trying to connect. Use 0 to wait indefinitely. "verify": Set to true to enable SSL cert validation (the default), false to disable, or supply the path to a CA bundle to enable verification using a custom certificate. "cert": Set to a string to specify the path to a file containing a PEM formatted certificate. If a password is required, then set an array containing the path to the PEM file followed by the the password required for the certificate. "ssl_key": Specify the path to a file containing a private SSL key in PEM format. If a password is required, then set an array containing the path to the SSL key followed by the password required for the certificate. "proxy": Specify an HTTP proxy (e.g. "http://username:password@192.168.16.1:10") "debug": Set to true to display all data sent over the wire

$flags : mixed = self::OPTIONS_NONE

Bitwise flags to apply when applying the options to the request. Defaults to no special options. 1 (OPTIONS_AS_DEFAULTS): When specified, options will only update a request when the value does not already exist on the request. This is only supported by "query" and "headers". Other bitwise options may be added in the future.

Return values
mixed

cloneRequestWithMethod()

Clone a request while changing the method. Emulates the behavior of {@see Guzzle\Http\Message\Request::clone}, but can change the HTTP method.

public cloneRequestWithMethod(RequestInterface $request, string $method) : RequestInterface
Parameters
$request : RequestInterface

Request to clone

$method : string

Method to set

Return values
RequestInterface

create()

Create a new request based on the HTTP method

public create(mixed $method, mixed $url[, mixed $headers = null ][, mixed $body = null ][, array<string|int, mixed> $options = array() ]) : RequestInterface
Parameters
$method : mixed

HTTP method (GET, POST, PUT, PATCH, HEAD, DELETE, ...)

$url : mixed

HTTP URL to connect to

$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$options : array<string|int, mixed> = array()

Array of options to apply to the request

Return values
RequestInterface

fromParts()

Create a request from URL parts as returned from parse_url()

public fromParts(mixed $method, array<string|int, mixed> $urlParts[, mixed $headers = null ][, mixed $body = null ][, mixed $protocol = 'HTTP' ][, mixed $protocolVersion = '1.1' ]) : RequestInterface
Parameters
$method : mixed

HTTP method (GET, POST, PUT, HEAD, DELETE, etc)

$urlParts : array<string|int, mixed>

URL parts containing the same keys as parse_url()

  • scheme: e.g. http
  • host: e.g. www.guzzle-project.com
  • port: e.g. 80
  • user: e.g. michael
  • pass: e.g. rocks
  • path: e.g. / OR /index.html
  • query: after the question mark ?
$headers : mixed = null

HTTP headers

$body : mixed = null

Body to send in the request

$protocol : mixed = 'HTTP'

Protocol (HTTP, SPYDY, etc)

$protocolVersion : mixed = '1.1'

1.0, 1.1, etc

Return values
RequestInterface

Search results