|
| __construct (array $options=null) |
| get ($url) |
| head ($url) |
| post ($url, $postData=null, $multipart=false) |
| query ($method, $url, $entityBody=null) |
| setHeader ($name, $value, $replace=true) |
| setHeaders (array $headers) |
| getRequestHeaders () |
| clearHeaders () |
| setCookies (array $cookies) |
| setAuthorization ($user, $pass) |
| setRedirect ($value, $max=null) |
| waitResponse ($value) |
| setTimeout ($value) |
| setStreamTimeout ($value) |
| setVersion ($value) |
| setCompress ($value) |
| setCharset ($value) |
| disableSslVerification () |
| setPrivateIp ($value) |
| setProxy ($proxyHost, $proxyPort=null, $proxyUser=null, $proxyPassword=null) |
| setOutputStream ($handler) |
| setBodyLengthMax ($bodyLengthMax) |
| download ($url, $filePath, string $method=Http\Method::GET, $entityBody=null) |
| saveFile ($filePath) |
| getEffectiveUrl () |
| setContextOptions (array $options) |
| getHeaders () |
| getCookies () |
| getStatus () |
| getResult () |
| getResponse () |
| getError () |
| getContentType () |
| getCharset () |
| getPeerAddress () |
| sendRequest (RequestInterface $request) |
| sendAsyncRequest (RequestInterface $request) |
| wait () |
| shouldFetchBody (callable $callback) |
| setResponseBuilder (Http\ResponseBuilderInterface $responseBuilder) |
Открытые члены унаследованные от DebugInterface |
| setDebugLevel (int $debugLevel) |
| getDebugLevel () |
См. определение в файле httpclient.php строка 23
◆ __construct()
__construct |
( |
array | $options = null | ) |
|
- Аргументы
-
array | null | $options | Optional array with options: "redirect" bool Follow redirects (default true). "redirectMax" int Maximum number of redirects (default 5). "waitResponse" bool Read the body or disconnect just after reading headers (default true). "socketTimeout" int Connection timeout in seconds (default 30). "streamTimeout" int Stream reading timeout in seconds (default 60 for waitResponse == true and 1 for waitResponse == false). "version" string HTTP version (HttpClient::HTTP_1_0, HttpClient::HTTP_1_1) (default "1.1"). "proxyHost" string Proxy host name/address. "proxyPort" int Proxy port number. "proxyUser" string Proxy username. "proxyPassword" string Proxy password. "compress" bool Accept gzip encoding (default false). "charset" string Charset for body in POST and PUT. "disableSslVerification" bool Pass true to disable ssl check. "bodyLengthMax" int Maximum length of the body. "privateIp" bool Enable or disable requests to private IPs (default true). "debugLevel" int Debug level using HttpDebug::* constants. "cookies" array of cookies for HTTP request. "headers" array of headers for HTTP request. "useCurl" bool Enable CURL (default false). "curlLogFile" string Full path to CURL log file. "sendEvents" bool Send events (default true). "responseBuilder" Http\ResponseBuilderInterface Response builder. Almost all options can be set separately with setters. |
См. определение в файле httpclient.php строка 101
◆ addError()
addError |
( |
| $code, |
|
|
| $message, |
|
|
| $triggerWarning = false ) |
|
protected |
◆ buildRequest()
buildRequest |
( |
RequestInterface | $request | ) |
|
|
protected |
◆ checkRequest()
checkRequest |
( |
RequestInterface | $request | ) |
|
|
protected |
◆ clearHeaders()
Clears all HTTP request header fields.
См. определение в файле httpclient.php строка 425
◆ createHandler()
createHandler |
( |
RequestInterface | $request, |
|
|
bool | $async = false ) |
|
protected |
- Аргументы
-
RequestInterface | $request | |
bool | $async | |
- Возвращает
- Http\Curl\Handler | Http\Socket\Handler
См. определение в файле httpclient.php строка 1001
◆ createPromise()
- Аргументы
-
Http\Curl\Handler | Http\Socket\Handler | $handler | |
Http\Queue | $queue | |
- Возвращает
- Http\Curl\Promise | Http\Socket\Promise
См. определение в файле httpclient.php строка 1056
◆ createQueue()
- Возвращает
- Http\Curl\Queue | Http\Socket\Queue
См. определение в файле httpclient.php строка 1068
◆ disableSslVerification()
disableSslVerification |
( |
| ) |
|
Disables ssl certificate verification.
- Возвращает
- $this
См. определение в файле httpclient.php строка 560
◆ download()
download |
( |
| $url, |
|
|
| $filePath, |
|
|
string | $method = Http\Method::GET, |
|
|
| $entityBody = null ) |
Downloads and saves a file.
- Аргументы
-
string | $url | URI to download. |
string | $filePath | Absolute file path. |
- Возвращает
- bool
См. определение в файле httpclient.php строка 635
◆ get()
Performs GET request.
- Аргументы
-
string | $url | Absolute URI e.g. "http://user:pass @ host:port/path/?query". |
- Возвращает
- string|bool Response entity string or false on error. Note, it's empty string if outputStream is set.
См. определение в файле httpclient.php строка 204
◆ getCharset()
Returns response content encoding.
- Возвращает
- string
См. определение в файле httpclient.php строка 787
◆ getContentType()
Returns response content type.
- Возвращает
- string
См. определение в файле httpclient.php строка 777
◆ getCookies()
Returns parsed HTTP response cookies.
- Возвращает
- HttpCookies
См. определение в файле httpclient.php строка 709
◆ getEffectiveUrl()
Returns URL of the last redirect if request was redirected, or initial URL if request was not redirected.
- Возвращает
- string
См. определение в файле httpclient.php строка 673
◆ getError()
Returns array of errors on failure.
- Возвращает
- array Array with "error_code" => "error_message" pair
См. определение в файле httpclient.php строка 767
◆ getHeaders()
Returns parsed HTTP response headers.
- Возвращает
- HttpHeaders
См. определение в файле httpclient.php строка 695
◆ getPeerAddress()
Returns remote peer ip address (only if privateIp = false).
- Возвращает
- string|false
См. определение в файле httpclient.php строка 797
◆ getRequestHeaders()
Returns HTTP request headers.
- Возвращает
- HttpHeaders
См. определение в файле httpclient.php строка 413
◆ getResponse()
Returns PSR-7 response.
- Возвращает
- Http\Response|null
См. определение в файле httpclient.php строка 757
◆ getResult()
Returns HTTP response entity string. Note, if outputStream is set, the result will be the empty string.
- Возвращает
- string
См. определение в файле httpclient.php строка 733
◆ getStatus()
Returns HTTP response status code.
- Возвращает
- int
См. определение в файле httpclient.php строка 719
◆ head()
Performs HEAD request.
- Аргументы
-
string | $url | Absolute URI e.g. "http://user:pass @ host:port/path/?query" |
- Возвращает
- HttpHeaders|bool Response headers or false on error.
См. определение в файле httpclient.php строка 219
◆ post()
post |
( |
| $url, |
|
|
| $postData = null, |
|
|
| $multipart = false ) |
Performs POST request.
- Аргументы
-
string | $url | Absolute URI e.g. "http://user:pass @ host:port/path/?query". |
array | string | resource | $postData | Entity of POST/PUT request. If it's resource handler then data will be read directly from the stream. |
boolean | $multipart | Whether to use multipart/form-data encoding. If true, method accepts file as a resource or as an array with keys 'resource' (or 'content') and optionally 'filename' and 'contentType' |
- Возвращает
- string|bool Response entity string or false on error. Note, it's empty string if outputStream is set.
См. определение в файле httpclient.php строка 236
◆ prepareMultipart()
prepareMultipart |
( |
| $postData | ) |
|
|
protected |
Performs multipart/form-data encoding. Accepts file as a resource or as an array with keys 'resource' (or 'content') and optionally 'filename' and 'contentType'.
- Аргументы
-
array | string | resource | $postData | Entity of POST/PUT request |
- Возвращает
- Http\MultipartStream|bool False on error
См. определение в файле httpclient.php строка 261
◆ query()
query |
( |
| $method, |
|
|
| $url, |
|
|
| $entityBody = null ) |
Perfoms HTTP request.
- Аргументы
-
string | $method | HTTP method (GET, POST, etc.). Note, it must be in UPPERCASE. |
string | $url | Absolute URI e.g. "http://user:pass @ host:port/path/?query". |
array | string | resource | Http\Stream | $entityBody | Entity body of the request. If it's resource handler then data will be read directly from the stream. |
- Возвращает
- bool Query result (true or false). Response entity string can be got via getResult() method. Note, it's empty string if outputStream is set.
См. определение в файле httpclient.php строка 290
◆ saveFile()
Saves a downloaded file.
- Аргументы
-
string | $filePath | Absolute file path. |
См. определение в файле httpclient.php строка 654
◆ sendAsyncRequest()
sendAsyncRequest |
( |
RequestInterface | $request | ) |
|
- Аргументы
-
- Возвращает
- PromiseInterface
- Исключения
-
ClientException
См. определение в файле httpclient.php строка 973
◆ sendRequest()
sendRequest |
( |
RequestInterface | $request | ) |
|
◆ setAuthorization()
setAuthorization |
( |
| $user, |
|
|
| $pass ) |
Sets Basic Authorization request header field.
- Аргументы
-
string | $user | Username. |
string | $pass | Password. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 453
◆ setBodyLengthMax()
setBodyLengthMax |
( |
| $bodyLengthMax | ) |
|
Sets the maximum body length that will be received in $this->readBody().
- Аргументы
-
- Возвращает
- $this
См. определение в файле httpclient.php строка 622
◆ setCharset()
Sets charset for the entity-body (used in the Content-Type request header field for POST and PUT).
- Аргументы
-
- Возвращает
- $this
См. определение в файле httpclient.php строка 549
◆ setCompress()
Sets compression option. Consider not to use the "compress" option with the output stream if a content can be large. Note, that compressed response is processed anyway if Content-Encoding response header field is set
- Аргументы
-
bool | $value | If true, "Accept-Encoding: gzip" will be sent. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 537
◆ setContextOptions()
setContextOptions |
( |
array | $options | ) |
|
Sets context options and parameters.
- Аргументы
-
array | $options | Context options and parameters |
- Возвращает
- $this
См. определение в файле httpclient.php строка 684
◆ setCookies()
setCookies |
( |
array | $cookies | ) |
|
Sets an array of cookies for HTTP request. Warning! Replaces 'Cookie' header.
- Аргументы
-
array | $cookies | Array of cookie_name => value pairs. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 436
◆ setHeader()
setHeader |
( |
| $name, |
|
|
| $value, |
|
|
| $replace = true ) |
Sets an HTTP request header.
- Аргументы
-
string | $name | Name of the header field. |
string | $value | Value of the field. |
bool | $replace | Replace existing header field with the same name or add one more. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 384
◆ setHeaders()
setHeaders |
( |
array | $headers | ) |
|
Sets an array of headers for HTTP request.
- Аргументы
-
array | $headers | Array of header_name => value pairs. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 399
◆ setOutputStream()
setOutputStream |
( |
| $handler | ) |
|
Sets the response output to the stream instead of the string result. Useful for large responses. Note, the stream must be readable/writable to support a compressed response. Note, in this mode the result string is empty. Note, only Http\Stream response body is supported.
- Аргументы
-
resource | $handler | File or stream handler. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 610
◆ setPrivateIp()
Enables or disables requests to private IPs.
- Аргументы
-
- Возвращает
- $this
См. определение в файле httpclient.php строка 572
◆ setProxy()
setProxy |
( |
| $proxyHost, |
|
|
| $proxyPort = null, |
|
|
| $proxyUser = null, |
|
|
| $proxyPassword = null ) |
Sets HTTP proxy for request.
- Аргументы
-
string | $proxyHost | Proxy host name or address (without "http://"). |
null | int | $proxyPort | Proxy port number. |
null | string | $proxyUser | Proxy username. |
null | string | $proxyPassword | Proxy password. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 587
◆ setRedirect()
setRedirect |
( |
| $value, |
|
|
| $max = null ) |
Sets redirect options.
- Аргументы
-
bool | $value | If true, do redirect (default true). |
null | int | $max | Maximum allowed redirect count. |
- Возвращает
- $this
См. определение в файле httpclient.php строка 466
◆ setResponseBuilder()
Sets a builder for a response.
- Аргументы
-
Http\ResponseBuilderInterface | $responseBuilder | |
- Возвращает
- $this
См. определение в файле httpclient.php строка 1115
◆ setStreamTimeout()
setStreamTimeout |
( |
| $value | ) |
|
Sets socket stream reading timeout.
- Аргументы
-
int | $value | Stream reading timeout in seconds; "0" means no timeout (default 60). |
- Возвращает
- $this
См. определение в файле httpclient.php строка 511
◆ setTimeout()
Sets connection timeout.
- Аргументы
-
int | $value | Connection timeout in seconds (default 30). |
- Возвращает
- $this
См. определение в файле httpclient.php строка 499
◆ setVersion()
Sets HTTP protocol version. In version 1.1 chunked response is possible.
- Аргументы
-
string | $value | Version "1.0" or "1.1" (default "1.0"). |
- Возвращает
- $this
См. определение в файле httpclient.php строка 523
◆ shouldFetchBody()
shouldFetchBody |
( |
callable | $callback | ) |
|
Sets a callback called before fetching a message body.
- Аргументы
-
- Возвращает
- $this
См. определение в файле httpclient.php строка 1103
◆ wait()
Waits for async promises and returns responses from processed promises.
- Возвращает
- ResponseInterface[]
См. определение в файле httpclient.php строка 1082
◆ waitResponse()
Sets response body waiting option.
- Аргументы
-
bool | $value | If true, wait for response body. If false, disconnect just after reading headers (default true). |
- Возвращает
- $this
См. определение в файле httpclient.php строка 482
◆ $bodyLengthMax
◆ $compress
◆ $contextOptions
◆ $curlLogFile
◆ $effectiveIp
◆ $effectiveUrl
◆ $error
◆ $headers
◆ $outputStream
◆ $privateIp
◆ $proxyHost
◆ $proxyPassword
◆ $proxyPort
◆ $proxyUser
◆ $queue
◆ $redirect
◆ $redirectCount
◆ $redirectMax
◆ $request
◆ $requestCharset
◆ $response
◆ $responseBuilder
Http ResponseBuilderInterface $responseBuilder |
|
protected |
◆ $sendEvents
◆ $shouldFetchBody
◆ $socketTimeout
$socketTimeout = self::DEFAULT_SOCKET_TIMEOUT |
|
protected |
◆ $sslVerify
◆ $streamTimeout
$streamTimeout = self::DEFAULT_STREAM_TIMEOUT |
|
protected |
◆ $useCurl
◆ $version
◆ $waitResponse
◆ DEFAULT_SOCKET_TIMEOUT
const DEFAULT_SOCKET_TIMEOUT = 30 |
◆ DEFAULT_STREAM_TIMEOUT
const DEFAULT_STREAM_TIMEOUT = 60 |
◆ DEFAULT_STREAM_TIMEOUT_NO_WAIT
const DEFAULT_STREAM_TIMEOUT_NO_WAIT = 1 |
◆ HTTP_1_0
◆ HTTP_1_1
◆ HTTP_DELETE
const HTTP_DELETE = 'DELETE' |
◆ HTTP_GET
◆ HTTP_HEAD
◆ HTTP_OPTIONS
const HTTP_OPTIONS = 'OPTIONS' |
◆ HTTP_PATCH
const HTTP_PATCH = 'PATCH' |
◆ HTTP_POST
◆ HTTP_PUT
Объявления и описания членов класса находятся в файле: