PHP Class Amp\Artax\Client

Inheritance: implements Amp\Artax\HttpClient
Show file Open project: amphp/artax Class Usage Examples

Public Methods

Method Description
__construct ( Amp\Artax\Cookie\CookieJar $cookieJar = null, HttpSocketPool $socketPool = null, Amp\Artax\WriterFactory $writerFactory = null )
request ( $uriOrRequest, array $options = [] ) : Amp\Promise Asynchronously request an HTTP resource
requestMulti ( array $urisAndRequests, array $options = [] ) : array[\Amp\Promise] Asynchronously request multiple HTTP resources
setAllOptions ( array $options ) : self Set multiple Client options at once
setOption ( integer $option, mixed $value ) : self Set an individual Client option

Private Methods

Method Description
afterHeaderWrite ( RequestCycle $cycle )
assignApplicableRequestCookies ( $request, array $options )
assignParsedResponse ( RequestCycle $cycle, array $parsedResponseArr )
assignRedirectRefererHeader ( $refererUri, $newUri, $request ) Clients must not add a Referer header when leaving an unencrypted resource and redirecting to an encrypted resource.
buildUriFromString ( $str )
canDecompressResponseBody ( Amp\Artax\Response $response )
collectRequestCycleWatchers ( RequestCycle $cycle )
consumeSocketData ( RequestCycle $cycle, $data )
dequeueNextRequest ( )
enableCrypto ( RequestCycle $cycle )
fail ( RequestCycle $cycle, $error )
finalizeRequest ( RequestCycle $cycle )
generateAuthorityFromUri ( Uri $uri )
generateCryptoOptions ( RequestCycle $cycle )
generateRawRequestHeaders ( Amp\Artax\Request $request )
generateRequestFromUri ( $uriOrRequest )
getRedirectUri ( RequestCycle $cycle )
inflateGzipBody ( Amp\Artax\Response $response )
isSocketDead ( $socketResource )
normalizeRequestAcceptHeader ( Amp\Artax\Request $request )
normalizeRequestBodyHeaders ( Amp\Artax\Request $request, array $options )
normalizeRequestEncodingHeaderForZlib ( Amp\Artax\Request $request, array $options )
normalizeRequestHostHeader ( Amp\Artax\Request $request, Uri $uri )
normalizeRequestMethod ( Amp\Artax\Request $request )
normalizeRequestProtocol ( Amp\Artax\Request $request )
normalizeRequestUserAgent ( Amp\Artax\Request $request, array $options )
onCryptoCompletion ( RequestCycle $cycle )
onReadableSocket ( RequestCycle $cycle )
onSocketResolve ( RequestCycle $cycle, $error, $socket )
parseSocketData ( RequestCycle $cycle )
proceedFrom100ContinueState ( RequestCycle $cycle )
processAggregateBody ( RequestCycle $cycle, Amp\Artax\AggregateBody $body )
processAggregateBodyHeaders ( RequestCycle $cycle, Amp\Artax\AggregateBody $body )
processDeadSocket ( RequestCycle $cycle )
redirect ( RequestCycle $cycle, Uri $newUri )
removePortFromHost ( $host )
requestExpects100Continue ( Amp\Artax\Request $request )
retry ( RequestCycle $cycle )
shouldCloseSocketAfterResponse ( Amp\Artax\Request $request, Amp\Artax\Response $response )
storeResponseCookie ( $requestDomain, $rawCookieStr )
writeBody ( RequestCycle $cycle, $body )
writeRequest ( RequestCycle $cycle )

Method Details

__construct() public method

public __construct ( Amp\Artax\Cookie\CookieJar $cookieJar = null, HttpSocketPool $socketPool = null, Amp\Artax\WriterFactory $writerFactory = null )
$cookieJar Amp\Artax\Cookie\CookieJar
$socketPool HttpSocketPool
$writerFactory Amp\Artax\WriterFactory

request() public method

Asynchronously request an HTTP resource
public request ( $uriOrRequest, array $options = [] ) : Amp\Promise
$options array An array specifying options applicable only for this request
return Amp\Promise A promise to resolve the request at some point in the future

requestMulti() public method

Note that this method is simply a convenience as storing the results of multiple calls to Client::request() in an array will achieve the same effect as Client::requestMulti().
public requestMulti ( array $urisAndRequests, array $options = [] ) : array[\Amp\Promise]
$urisAndRequests array An array of URI strings and/or Request instances
$options array An array specifying options applicable only for this request batch
return array[\Amp\Promise]

setAllOptions() public method

Set multiple Client options at once
public setAllOptions ( array $options ) : self
$options array An array of the form [OP_CONSTANT => $value]
return self

setOption() public method

Set an individual Client option
public setOption ( integer $option, mixed $value ) : self
$option integer A Client option constant
$value mixed The option value to assign
return self