CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • CookieCollection
  • FormData
  • Message
  • Request
  • Response

Interfaces

  • AdapterInterface

Class Request

Implements methods for HTTP requests.

Used by Cake\Http\Client to contain request information for making requests.

Cake\Http\Client\Message
Extended by Cake\Http\Client\Request implements Psr\Http\Message\RequestInterface uses Zend\Diactoros\RequestTrait
Namespace: Cake\Http\Client
Location: Http/Client/Request.php

Inherited Constants

  • 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_NON_AUTHORITATIVE_INFORMATION, STATUS_NO_CONTENT, STATUS_OK, STATUS_SEE_OTHER, STATUS_TEMPORARY_REDIRECT

Inherited Magic Properties

  • headers

Inherited Properties

  • _body, _cookies

Method Summary

  • __construct() public
    Constructor
  • addHeaders() protected
    Add an array of headers to the request.
  • body() public
    Get/set the body/payload for the message.
  • cookie() public deprecated
    Get/Set cookie values.
  • header() public deprecated
    Get/Set headers into the request.
  • method() public deprecated
    Get/Set the HTTP method.
  • url() public deprecated
    Get/Set the url for the request.
  • version() public deprecated
    Get/Set HTTP version.

Method Detail

__construct() public ¶

__construct( string $url = '' , string $method = self::METHOD_GET , array $headers = [] , array|string|null $data = null )

Constructor

Provides backwards compatible defaults for some properties.

Parameters
string $url optional ''
The request URL
string $method optional self::METHOD_GET
The HTTP method to use.
array $headers optional []
The HTTP headers to set.
array|string|null $data optional null
The request body to use.

addHeaders() protected ¶

addHeaders( array $headers )

Add an array of headers to the request.

Parameters
array $headers
The headers to add.

body() public ¶

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.

Parameters
string|array|null $body optional null
The body for the request. Leave null for get
Returns
mixed
Either $this or the body value.
Overrides
Cake\Http\Client\Message::body()

cookie() public deprecated ¶

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']);
Deprecated

3.5.0 No longer used. CookieCollections now add Cookie header to the request before sending. Use Cake\Http\Cookie\CookieCollection::addToRequest() to make adding cookies to a request easier.


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.

header() public deprecated ¶

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']);

Warning This method mutates the request in-place for backwards compatibility reasons, and is not part of the PSR7 interface.

Deprecated
3.3.0 Use withHeader() and getHeaderLine() instead.
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.

method() public deprecated ¶

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.

Deprecated
3.3.0 Use getMethod() and withMethod() instead.
Parameters
string|null $method optional null
The method for the request.
Returns

$this|string Either this or the current method.
Throws
Cake\Core\Exception\Exception
On invalid methods.

url() public deprecated ¶

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.

Deprecated
3.3.0 Use getUri() and withUri() instead.
Parameters
string|null $url optional null
The url for the request. Leave null for get
Returns

$this|string Either $this or the url value.

version() public deprecated ¶

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.

Deprecated
3.3.0 Use getProtocolVersion() and withProtocolVersion() instead.
Parameters
string|null $version optional null
The HTTP version.
Returns

$this|string Either $this or the HTTP version.

Methods inherited from Cake\Http\Client\Message

cookies() public ¶

cookies( )

Get all cookies

Returns
array

headers() public deprecated ¶

headers( )

Get all headers

Deprecated
3.3.0 Use getHeaders() instead.
Returns
array
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs