# Class yii\httpclient\Response

Inheritance | yii\httpclient\Response » yii\httpclient\Message » yii\base\Component » yii\base\BaseObject
Implements | yii\base\Configurable
Available since version | 2.0
Source Code | https://github.com/yiisoft/yii2-httpclient/blob/master/Response.php

Response represents HTTP request response.

## Public Properties

Hide inherited properties

Property | Type | Description | Defined By
--- | --- | --- | ---
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. This property is read-only. | yii\base\Component
$client | yii\httpclient\Client | Owner client instance. | yii\httpclient\Message
$content | string | Raw body. | yii\httpclient\Message
$cookies | yii\web\CookieCollection|yii\web\Cookie[] | The cookie collection. Note that the type of this property differs in getter and setter. See getCookies() and setCookies() for details. | yii\httpclient\Message
$data | mixed | Content data fields. | yii\httpclient\Message
$format | string | Body format name. | yii\httpclient\Message
$headers | yii\web\HeaderCollection | The header collection. Note that the type of this property differs in getter and setter. See getHeaders() and setHeaders() for details. | yii\httpclient\Message
$isOk | boolean | Whether response is OK. This property is read-only. | yii\httpclient\Response
$statusCode | string | Status code. This property is read-only. | yii\httpclient\Response

## Public Methods

Hide inherited methods

Method | Description | Defined By
--- | --- | ---
__call() | Calls the named method which is not a class method. | yii\base\Component
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component
__construct() | Constructor. | yii\base\BaseObject
__get() | Returns the value of a component property. | yii\base\Component
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component
__set() | Sets the value of a component property. | yii\base\Component
__toString() | PHP magic method that returns the string representation of this object. | yii\httpclient\Message
__unset() | Sets a component property to be null. | yii\base\Component
addCookies() | Adds more cookies to the already defined ones. | yii\httpclient\Message
addData() | Adds data fields to the existing ones. | yii\httpclient\Message
addHeaders() | Adds more headers to the already defined ones. | yii\httpclient\Message
attachBehavior() | Attaches a behavior to this component. | yii\base\Component
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component
className() | Returns the fully qualified name of this class. | yii\base\BaseObject
composeHeaderLines() | Composes raw header lines from $headers. | yii\httpclient\Message
detachBehavior() | Detaches a behavior from the component. | yii\base\Component
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component
getBehavior() | Returns the named behavior object. | yii\base\Component
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component
getContent() | Returns HTTP message raw content. | yii\httpclient\Message
getCookies() | Returns the cookie collection. | yii\httpclient\Response
getData() | Returns the data fields, parsed from raw content. | yii\httpclient\Response
getFormat() | Returns body format. | yii\httpclient\Message
getHeaders() | Returns the header collection. | yii\httpclient\Message
getIsOk() | Checks if response status code is OK (status code = 20x) | yii\httpclient\Response
getStatusCode() | Returns status code. | yii\httpclient\Response
hasContent() | Checks if content with provided name exists | yii\httpclient\Message
hasCookies() | Checks of HTTP message contains any cookie. | yii\httpclient\Message
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component
hasHeaders() | Checks of HTTP message contains any header. | yii\httpclient\Message
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component
init() | Initializes the object. | yii\base\BaseObject
off() | Detaches an existing event handler from this component. | yii\base\Component
on() | Attaches an event handler to an event. | yii\base\Component
setContent() | Sets the HTTP message raw content. | yii\httpclient\Message
setCookies() | Sets the cookies associated with HTTP message. | yii\httpclient\Message
setData() | Sets the data fields, which composes message content. | yii\httpclient\Message
setFormat() | Sets body format. | yii\httpclient\Message
setHeaders() | Sets the HTTP headers associated with HTTP message. | yii\httpclient\Message
toString() | Returns string representation of this HTTP message. | yii\httpclient\Message
trigger() | Triggers an event. | yii\base\Component

## Protected Methods

Hide inherited methods

Method | Description | Defined By
--- | --- | ---
defaultFormat() | Returns default format automatically detected from headers and content. | yii\httpclient\Response
detectFormatByContent() | Detects response format from raw content. | yii\httpclient\Response
detectFormatByHeaders() | Detects format from headers. | yii\httpclient\Response

## Property Details

$isOk public property

Whether response is OK. This property is read-only.

public boolean $isOk = null
$statusCode public property

Status code. This property is read-only.

public string $statusCode = null

## Method Details

defaultFormat() protected method

Returns default format automatically detected from headers and content.

protected string|null defaultFormat ( )
return | string|null | Format name, 'null' - if detection failed.

detectFormatByContent() protected method

Detects response format from raw content.

protected null|string detectFormatByContent ( $content )
$content | string | Raw response content.
return | null|string | Format name, 'null' - if detection failed.

detectFormatByHeaders() protected method

Detects format from headers.

protected null|string detectFormatByHeaders ( yii\web\HeaderCollection $headers )
$headers | yii\web\HeaderCollection | Source headers.
return | null|string | Format name, 'null' - if detection failed.

getCookies() public method

Returns the cookie collection.

The cookie collection contains the cookies associated with HTTP message.

public yii\web\CookieCollection|yii\web\Cookie[] getCookies ( )
return | yii\web\CookieCollection|yii\web\Cookie[] | The cookie collection.

getData() public method

Returns the data fields, parsed from raw content.

public mixed getData ( )
return | mixed | Content data fields.

getIsOk() public method

Checks if response status code is OK (status code = 20x)

public boolean getIsOk ( )
return | boolean | Whether response is OK.
throws | yii\httpclient\Exception |

getStatusCode() public method

Returns status code.

public string getStatusCode ( )
return | string | Status code.
throws | yii\httpclient\Exception | on failure.