Class yii\httpclient\Response

Inheritanceyii\httpclient\Response » yii\httpclient\Message » yii\base\Component
Available since version2.0

Response represents HTTP request response.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$client yii\httpclient\Client Owner client instance. yii\httpclient\Message

Public Methods

Hide inherited methods

MethodDescriptionDefined 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

Hide inherited methods

MethodDescriptionDefined 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

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.