Implements methods for HTTP requests.
Used by Cake\Http\Client to contain request information for making requests.
METHOD_DELETE
, METHOD_GET
, METHOD_HEAD
, METHOD_OPTIONS
, METHOD_PATCH
, METHOD_POST
, METHOD_PUT
, METHOD_TRACE
, STATUS_ACCEPTED
, STATUS_CREATED
, STATUS_FOUND
, STATUS_MOVED_PERMANENTLY
, STATUS_OK
, STATUS_SEE_OTHER
, STATUS_TEMPORARY_REDIRECT
__construct( string $url '' , string $method self::METHOD_GET , array $headers [] , array|string|null $data null )
Constructor
Provides backwards compatible defaults for some properties.
$url
optional '' $method
optional self::METHOD_GET $headers
optional [] $data
optional null addHeaders( array $headers )
Add an array of headers to the request.
$headers
body( string|array|null $body null )
Get/set the body/payload for the message.
Array data will be serialized with Cake\Http\FormData, and the content-type will be set.
$body
optional null Cake\Http\Client\Message::body()
cookie( string $name , string|null $value null )
Get/Set cookie values.
$request->cookie('session');
$request->cookie('session', '123456');
$request->cookie(['test' => 'value', 'split' => 'banana']);
$name
$value
optional null header( string|array|null $name null , string|null $value null )
Get/Set headers into the request.
You can get the value of a header, or set one/many headers. Headers are set / fetched in a case insensitive way.
$request->header('Content-Type');
$request->header('Content-Type', 'application/json');
$request->header(['Connection' => 'close', 'User-Agent' => 'CakePHP']);
Warning This method mutates the request in-place for backwards compatibility reasons, and is not part of the PSR7 interface.
$name
optional null $value
optional null method( string|null $method null )
Get/Set the HTTP method.
Warning This method mutates the request in-place for backwards compatibility reasons, and is not part of the PSR7 interface.
$method
optional null Cake\Core\Exception\Exception
url( string|null $url null )
Get/Set the url for the request.
Warning This method mutates the request in-place for backwards compatibility reasons, and is not part of the PSR7 interface.
$url
optional null version( string|null $version null )
Get/Set HTTP version.
Warning This method mutates the request in-place for backwards compatibility reasons, and is not part of the PSR7 interface.
$version
optional null headers( )
Get all headers
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.Http.Client.Request.html