Class yii\httpclient\Response
| Inheritance | yii\httpclient\Response » yii\httpclient\Message » yii\base\Component |
|---|---|
| Available since version | 2.0 |
Response represents HTTP request response.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $client | yii\httpclient\Client | Owner client instance. | yii\httpclient\Message |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __toString() | PHP magic method that returns the string representation of this object. | yii\httpclient\Message |
| 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 |
| composeHeaderLines() | Composes raw header lines from \yii\httpclient\headers. | yii\httpclient\Message |
| 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 |
| hasCookies() | Checks of HTTP message contains any cookie. | yii\httpclient\Message |
| hasHeaders() | Checks of HTTP message contains any header. | yii\httpclient\Message |
| 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 |
Protected 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 |
Method Details
Returns default format automatically detected from headers and content.
| protected string|null defaultFormat ( ) | ||
| return | string|null | Format name, 'null' - if detection failed. |
|---|---|---|
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. |
|---|---|---|
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. |
|---|---|---|
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. |
|---|---|---|
Returns the data fields, parsed from raw content.
| public mixed getData ( ) | ||
| return | mixed | Content data fields. |
|---|---|---|
Checks if response status code is OK (status code = 20x)
| public boolean getIsOk ( ) | ||
| return | boolean | Whether response is OK. |
|---|---|---|
| throws | yii\httpclient\Exception | |
Returns status code.
| public string getStatusCode ( ) | ||
| return | string | Status code. |
|---|---|---|
| throws | yii\httpclient\Exception | on failure. |