PHP Class yii\httpclient\Request

Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends Message
Mostrar archivo Open project: yiisoft/yii2-httpclient Class Usage Examples

Public Methods

Method Description
addContent ( string $name, string $content, array $options = [] ) Adds a content part for multi-part content request.
addData ( $data )
addFile ( string $name, string $fileName, array $options = [] ) Adds a file for upload as multi-part content.
addFileContent ( string $name, string $content, array $options = [] ) Adds a string as a file upload.
addOptions ( array $options ) Adds more options to already defined ones.
afterSend ( Response $response ) This method is invoked right after this request is sent.
beforeSend ( ) This method is invoked right before this request is sent.
composeHeaderLines ( )
getFullUrl ( ) : string Returns full target URL, including [[Client::baseUrl]] as a string.
getMethod ( ) : string
getOptions ( ) : array
getUrl ( ) : string | array Returns target URL.
prepare ( ) Prepares this request instance for sending.
send ( ) : Response Sends this request.
setData ( $data )
setMethod ( string $method )
setOptions ( array $options ) Following options are supported: - timeout: int, the maximum number of seconds to allow request to be executed.
setUrl ( string | array $url ) Sets target URL.
toString ( )

Private Methods

Method Description
composeCookieHeader ( ) : string
composeFormInputs ( array $data, string $baseKey = '' ) : array Composes given data as form inputs submitted values, taking in account nested arrays.
createFullUrl ( array | string $url ) : string Normalizes given URL value, filling it with actual string URL value.
getFormatter ( ) : yii\httpclient\FormatterInterface
prepareMultiPartContent ( array $content ) Prepares multi-part content.

Method Details

addContent() public method

Adds a content part for multi-part content request.
public addContent ( string $name, string $content, array $options = [] )
$name string part (form input) name.
$content string content.
$options array content part options, valid options are: - contentType - string, part content type - fileName - string, name of the uploading file - mimeType - string, part content type in case of file uploading

addData() public method

public addData ( $data )

addFile() public method

Adds a file for upload as multi-part content.
See also: addContent()
public addFile ( string $name, string $fileName, array $options = [] )
$name string part (form input) name
$fileName string full name of the source file.
$options array content part options, valid options are: - fileName - string, base name of the uploading file, if not set it base name of the source file will be used. - mimeType - string, file mime type, if not set it will be determine automatically from source file.

addFileContent() public method

Adds a string as a file upload.
See also: addContent()
public addFileContent ( string $name, string $content, array $options = [] )
$name string part (form input) name
$content string file content.
$options array content part options, valid options are: - fileName - string, base name of the uploading file. - mimeType - string, file mime type, if not set it 'application/octet-stream' will be used.

addOptions() public method

Please refer to Request::setOptions on how to specify options.
public addOptions ( array $options )
$options array additional options

afterSend() public method

The method will invoke [[Client::afterSend()]] and trigger the [[EVENT_AFTER_SEND]] event.
Since: 2.0.1
public afterSend ( Response $response )
$response Response received response instance.

beforeSend() public method

The method will invoke [[Client::beforeSend()]] and trigger the [[EVENT_BEFORE_SEND]] event.
Since: 2.0.1
public beforeSend ( )

composeHeaderLines() public method

public composeHeaderLines ( )

getFullUrl() public method

Returns full target URL, including [[Client::baseUrl]] as a string.
public getFullUrl ( ) : string
return string full target URL.

getMethod() public method

public getMethod ( ) : string
return string request method

getOptions() public method

public getOptions ( ) : array
return array request options.

getUrl() public method

Returns target URL.
public getUrl ( ) : string | array
return string | array target URL or URL parameters

prepare() public method

This method should be invoked by transport before sending a request. Do not call this method unless you know what you are doing.
public prepare ( )

send() public method

Sends this request.
public send ( ) : Response
return Response response instance.

setData() public method

public setData ( $data )

setMethod() public method

public setMethod ( string $method )
$method string request method

setOptions() public method

- proxy: string, URI specifying address of proxy server. (e.g. tcp://proxy.example.com:5100). - userAgent: string, the contents of the "User-Agent: " header to be used in a HTTP request. - followLocation: bool, whether to follow any "Location: " header that the server sends as part of the HTTP header. - maxRedirects: int, the max number of redirects to follow. - protocolVersion: float|string, HTTP protocol version. - sslVerifyPeer: bool, whether verification of the peer's certificate should be performed. - sslCafile: string, location of Certificate Authority file on local filesystem which should be used with the 'sslVerifyPeer' option to authenticate the identity of the remote peer. - sslCapath: string, a directory that holds multiple CA certificates. You may set options using keys, which are specific to particular transport, like [CURLOPT_VERBOSE => true] in case there is a necessity for it.
public setOptions ( array $options )
$options array request options.

setUrl() public method

Sets target URL.
public setUrl ( string | array $url )
$url string | array use a string to represent a URL (e.g. `http://some-domain.com`, `item/list`), or an array to represent a URL with query parameters (e.g. `['item/list', 'param1' => 'value1']`).

toString() public method

public toString ( )