Class Request
Implements methods for HTTP requests.
Used by Cake\Network\Http\Client to contain request information for making requests.
- Cake\Network\Http\Message
-
Cake\Network\Http\Request
Inherited Constants
Properties summary
Method Summary
Method Detail
cookie() public ¶
cookie( string $name , string|null $value = null )
Get/Set cookie values.
Getting a cookie
$request->cookie('session');
Setting one cookie
$request->cookie('session', '123456');
Setting multiple headers
$request->cookie(['test' => 'value', 'split' => 'banana']);
Parameters
- string $name
- The name of the cookie to get/set
- string|null $value optional null
- Either the value or null when getting values.
Returns
mixed
Either $this or the cookie value.
Either $this or the cookie value.
header() public ¶
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.
Getting headers
$request->header('Content-Type');
Setting one header
$request->header('Content-Type', 'application/json');
Setting multiple headers
$request->header(['Connection' => 'close', 'User-Agent' => 'CakePHP']);
Parameters
- string|array|null $name optional null
- The name to get, or array of multiple values to set.
- string|null $value optional null
- The value to set for the header.
Returns
mixed
Either $this when setting or header value when getting.
Either $this when setting or header value when getting.
method() public ¶
method( string|null $method = null )
Get/Set the HTTP method.
Parameters
- string|null $method optional null
- The method for the request.
Returns
$this|string Either this or the current method.
Throws
url() public ¶
url( string|null $url = null )
Get/Set the url for the request.
Parameters
- string|null $url optional null
- The url for the request. Leave null for get
Returns
$this|string Either $this or the url value.
Methods inherited from Cake\Network\Http\Message
_normalizeHeader() protected ¶
_normalizeHeader( string $name )
Normalize header names to Camel-Case form.
Parameters
- string $name
- The header name to normalize.
Returns
string
Normalized header name.
Normalized header name.