PHP 클래스 yii\httpclient\Client

부터: 2.0
저자: Paul Klimov ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2-httpclient 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$baseUrl base request URL.
$contentLoggingMaxSize maximum symbols count of the request content, which should be taken to compose a log and profile messages. Exceeding content will be truncated.
$formatters the formatters for converting data into the content of the specified [[format]]. The array keys are the format names, and the array values are the corresponding configurations for creating the formatter objects.
$parsers the parsers for converting content of the specified [[format]] into the data. The array keys are the format names, and the array values are the corresponding configurations for creating the parser objects.
$requestConfig request object configuration.
$responseConfig response config configuration.

공개 메소드들

메소드 설명
afterSend ( Request $request, Response $response ) This method is invoked right after request is sent.
batchSend ( array $requests ) : Response[] Performs multiple HTTP requests in parallel.
beforeSend ( Request $request ) This method is invoked right before request is sent.
createRequest ( ) : Request
createRequestLogToken ( string $method, string $url, array $headers, string $content ) : string Composes the log/profiling message token for the given HTTP request parameters.
createResponse ( string $content = null, array $headers = [] ) : Response Creates a response instance.
delete ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request Creates 'DELETE' request.
get ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request Creates 'GET' request.
getFormatter ( string $format ) : yii\httpclient\FormatterInterface Returns HTTP message formatter instance for the specified format.
getParser ( string $format ) : yii\httpclient\ParserInterface Returns HTTP message parser instance for the specified format.
getTransport ( ) : Transport
head ( string $url, array $headers = [], array $options = [] ) : Request Creates 'HEAD' request.
options ( string $url, array $options = [] ) : Request Creates 'OPTIONS' request.
patch ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request Creates 'PATCH' request.
post ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request Creates 'POST' request.
put ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request Creates 'PUT' request.
send ( Request $request ) : Response Performs given request.
setTransport ( Transport | array | string $transport ) Sets the HTTP message transport. It can be specified in one of the following forms:

비공개 메소드들

메소드 설명
createRequestShortcut ( string $method, string $url, array | string $data, array $headers, array $options ) : Request

메소드 상세

afterSend() 공개 메소드

The method will trigger the [[EVENT_AFTER_SEND]] event.
부터: 2.0.1
public afterSend ( Request $request, Response $response )
$request Request request instance.
$response Response received response instance.

batchSend() 공개 메소드

This method accepts an array of the Request objects and returns an array of the Response objects. Keys of the response array correspond the ones from request array. php $client = new Client(); $requests = [ 'news' => $client->get('http://domain.com/news'), 'friends' => $client->get('http://domain.com/user/friends', ['userId' => 12]), ]; $responses = $client->batchSend($requests); var_dump($responses['news']->isOk); var_dump($responses['friends']->isOk);
public batchSend ( array $requests ) : Response[]
$requests array requests to perform.
리턴 Response[] responses list.

beforeSend() 공개 메소드

The method will trigger the [[EVENT_BEFORE_SEND]] event.
부터: 2.0.1
public beforeSend ( Request $request )
$request Request request instance.

createRequest() 공개 메소드

public createRequest ( ) : Request
리턴 Request request instance.

createRequestLogToken() 공개 메소드

This method should be used by transports during request sending logging.
public createRequestLogToken ( string $method, string $url, array $headers, string $content ) : string
$method string request method name.
$url string request URL.
$headers array request headers.
$content string request content.
리턴 string log token.

createResponse() 공개 메소드

Creates a response instance.
public createResponse ( string $content = null, array $headers = [] ) : Response
$content string raw content
$headers array headers list.
리턴 Response request instance.

delete() 공개 메소드

Creates 'DELETE' request.
public delete ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.

get() 공개 메소드

Creates 'GET' request.
public get ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.

getFormatter() 공개 메소드

Returns HTTP message formatter instance for the specified format.
public getFormatter ( string $format ) : yii\httpclient\FormatterInterface
$format string format name.
리턴 yii\httpclient\FormatterInterface formatter instance.

getParser() 공개 메소드

Returns HTTP message parser instance for the specified format.
public getParser ( string $format ) : yii\httpclient\ParserInterface
$format string format name
리턴 yii\httpclient\ParserInterface parser instance.

getTransport() 공개 메소드

public getTransport ( ) : Transport
리턴 Transport HTTP message transport instance.

head() 공개 메소드

Creates 'HEAD' request.
public head ( string $url, array $headers = [], array $options = [] ) : Request
$url string target URL.
$headers array request headers.
$options array request options.
리턴 Request request instance.

options() 공개 메소드

Creates 'OPTIONS' request.
public options ( string $url, array $options = [] ) : Request
$url string target URL.
$options array request options.
리턴 Request request instance.

patch() 공개 메소드

Creates 'PATCH' request.
public patch ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.

post() 공개 메소드

Creates 'POST' request.
public post ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.

put() 공개 메소드

Creates 'PUT' request.
public put ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.

send() 공개 메소드

Performs given request.
public send ( Request $request ) : Response
$request Request request to be sent.
리턴 Response response instance.

setTransport() 공개 메소드

- an instance of Transport: actual transport object to be used - a string: representing the class name of the object to be created - a configuration array: the array must contain a class element which is treated as the object class, and the rest of the name-value pairs will be used to initialize the corresponding object properties - a PHP callable: either an anonymous function or an array representing a class method ([$class or $object, $method]). The callable should return a new instance of the object being created.
public setTransport ( Transport | array | string $transport )
$transport Transport | array | string HTTP message transport

프로퍼티 상세

$baseUrl 공개적으로 프로퍼티

base request URL.
public $baseUrl

$contentLoggingMaxSize 공개적으로 프로퍼티

maximum symbols count of the request content, which should be taken to compose a log and profile messages. Exceeding content will be truncated.
또한 보기: createRequestLogToken()
public $contentLoggingMaxSize

$formatters 공개적으로 프로퍼티

the formatters for converting data into the content of the specified [[format]]. The array keys are the format names, and the array values are the corresponding configurations for creating the formatter objects.
public $formatters

$parsers 공개적으로 프로퍼티

the parsers for converting content of the specified [[format]] into the data. The array keys are the format names, and the array values are the corresponding configurations for creating the parser objects.
public $parsers

$requestConfig 공개적으로 프로퍼티

request object configuration.
public $requestConfig

$responseConfig 공개적으로 프로퍼티

response config configuration.
public $responseConfig