PHP Class yii\httpclient\Message

Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\base\Component
Datei anzeigen Open project: yiisoft/yii2-httpclient Class Usage Examples

Public Properties

Property Type Description
$client owner client instance.

Public Methods

Method Description
__toString ( ) : string PHP magic method that returns the string representation of this object.
addCookies ( array $cookies ) Adds more cookies to the already defined ones.
addData ( array $data ) Adds data fields to the existing ones.
addHeaders ( array $headers ) Adds more headers to the already defined ones.
composeHeaderLines ( ) : array Composes raw header lines from [[headers]].
getContent ( ) : string Returns HTTP message raw content.
getCookies ( ) : CookieCollection | Cookie[] Returns the cookie collection.
getData ( ) : mixed Returns the data fields, parsed from raw content.
getFormat ( ) : string Returns body format.
getHeaders ( ) : HeaderCollection Returns the header collection.
hasCookies ( ) : boolean Checks of HTTP message contains any cookie.
hasHeaders ( ) : boolean Checks of HTTP message contains any header.
setContent ( string $content ) Sets the HTTP message raw content.
setCookies ( CookieCollection | Cookie[] | array $cookies ) Sets the cookies associated with HTTP message.
setData ( mixed $data ) Sets the data fields, which composes message content.
setFormat ( string $format ) Sets body format.
setHeaders ( array | HeaderCollection $headers ) Sets the HTTP headers associated with HTTP message.
toString ( ) : string Returns string representation of this HTTP message.

Protected Methods

Method Description
defaultFormat ( ) : string Returns default format name.

Method Details

__toString() public method

PHP magic method that returns the string representation of this object.
public __toString ( ) : string
return string the string representation of this object.

addCookies() public method

Adds more cookies to the already defined ones.
public addCookies ( array $cookies )
$cookies array additional cookies.

addData() public method

Adds data fields to the existing ones.
Since: 2.0.1
public addData ( array $data )
$data array additional content data fields.

addHeaders() public method

Adds more headers to the already defined ones.
public addHeaders ( array $headers )
$headers array additional headers in format: [headerName => headerValue]

composeHeaderLines() public method

Each line will be a string in format: 'header-name: value'.
public composeHeaderLines ( ) : array
return array raw header lines.

defaultFormat() protected method

Returns default format name.
protected defaultFormat ( ) : string
return string default format name.

getContent() public method

Returns HTTP message raw content.
public getContent ( ) : string
return string raw body.

getCookies() public method

The cookie collection contains the cookies associated with HTTP message.
public getCookies ( ) : CookieCollection | Cookie[]
return yii\web\CookieCollection | yii\web\Cookie[] the cookie collection.

getData() public method

Returns the data fields, parsed from raw content.
public getData ( ) : mixed
return mixed content data fields.

getFormat() public method

Returns body format.
public getFormat ( ) : string
return string body format name.

getHeaders() public method

The header collection contains the HTTP headers associated with HTTP message.
public getHeaders ( ) : HeaderCollection
return yii\web\HeaderCollection the header collection

hasCookies() public method

Using this method you are able to check cookie presence without instantiating [[CookieCollection]].
public hasCookies ( ) : boolean
return boolean whether message contains any cookie.

hasHeaders() public method

Using this method you are able to check cookie presence without instantiating [[HeaderCollection]].
public hasHeaders ( ) : boolean
return boolean whether message contains any header.

setContent() public method

Sets the HTTP message raw content.
public setContent ( string $content )
$content string raw content.

setCookies() public method

Sets the cookies associated with HTTP message.
public setCookies ( CookieCollection | Cookie[] | array $cookies )
$cookies yii\web\CookieCollection | yii\web\Cookie[] | array cookie collection or cookies list.

setData() public method

Sets the data fields, which composes message content.
public setData ( mixed $data )
$data mixed content data fields.

setFormat() public method

Sets body format.
public setFormat ( string $format )
$format string body format name.

setHeaders() public method

Sets the HTTP headers associated with HTTP message.
public setHeaders ( array | HeaderCollection $headers )
$headers array | yii\web\HeaderCollection headers collection or headers list in format: [headerName => headerValue]

toString() public method

Returns string representation of this HTTP message.
public toString ( ) : string
return string the string representation of this HTTP message.

Property Details

$client public_oe property

owner client instance.
public $client