CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.0 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Http

Namespaces

  • Cake\Network\Http\Adapter
  • Cake\Network\Http\Auth
  • Cake\Network\Http\FormData

Classes

  • Client

    The end user interface for doing HTTP requests.

    Scoped clients

    If you're doing multiple requests to the same hostname its often convenient to use the constructor arguments to create a scoped client. This allows you to keep your code DRY and not repeat hostnames, authentication, and other options.

    Doing requests

    Once you've created an instance of Client you can do requests using several methods. Each corresponds to a different HTTP method.

    • get()
    • post()
    • put()
    • delete()
    • patch()

    Cookie management

    Client will maintain cookies from the responses done with a client instance. These cookies will be automatically added to future requests to matching hosts. Cookies will respect the Expires, Path and Domain attributes. You can get the list of currently stored cookies using the cookies() method.

    You can use the 'cookieJar' constructor option to provide a custom cookie jar instance you've restored from cache/disk. By default an empty instance of Cake\Network\Http\CookieCollection will be created.

    Sending request bodies

    By default any POST/PUT/PATCH/DELETE request with $data will send their data as multipart/form-data.

    When sending request bodies you can use the type option to set the Content-Type for the request:

    $http->get('/users', [], ['type' => 'json']);

    The type option sets both the Content-Type and Accept header, to the same mime type. When using type you can use either a full mime type or an alias. If you need different types in the Accept and Content-Type headers you should set them manually and not use type

    Using authentication

    By using the auth key you can use authentication. The type sub option can be used to specify which authentication strategy you want to use. CakePHP comes with a few built-in strategies:

    • Basic
    • Digest
    • Oauth

    Using proxies

    By using the proxy key you can set authentication credentials for a proxy if you need to use one.. The type sub option can be used to specify which authentication strategy you want to use. CakePHP comes with built-in support for basic authentication.

  • CookieCollection

    Container class for cookies used in Http\Client.

    Provides cookie jar like features for storing cookies between requests, as well as appending cookies to new requests.

  • FormData

    Provides an interface for building multipart/form-encoded message bodies.

    Used by Http\Client to upload POST/PUT data and files.

  • Message

    Base class for other HTTP requests/responses

    Defines some common helper methods, constants and properties.

  • Request

    Implements methods for HTTP requests.

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

  • Response

    Implements methods for HTTP responses.

    All of the following examples assume that $response is an instance of this class.

    Get header values

    Header names are case-insensitive, but normalized to Title-Case when the response is parsed.

    $val = $response->header('content-type');

    Will read the Content-Type header. You can get all set headers using:

    $response->header();

    You can also get at the headers using object access. When getting headers with object access, you have to use case-sensitive header names:

    $val = $response->headers['Content-Type'];

    Get the response body

    You can access the response body using:

    $content = $response->body();

    You can also use object access:

    $content = $response->body;

    If your response body is in XML or JSON you can use special content type specific accessors to read the decoded data. JSON data will be returned as arrays, while XML data will be returned as SimpleXML nodes:

    // Get as xml
    $content = $response->xml
    // Get as json
    $content = $response->json

    If the response cannot be decoded, null will be returned.

    Check the status code

    You can access the response status code using:

    $content = $response->statusCode();

    You can also use object access:

    $content = $response->code;
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs