Response
in package
The response provides a facade to manipulate HttpResponses.
Tags
Table of Contents
Properties
- $awsErrorFactory : AwsErrorFactoryInterface
- $bodyDownloaded : bool
- A flag that indicated that the body have been downloaded.
- $debug : bool
- $didThrow : bool
- A flag that indicated that an exception has been thrown to the user.
- $endpointCache : EndpointCache|null
- $exceptionMapping : array<string, HttpException>>
- $httpClient : HttpClientInterface
- $httpResponse : ResponseInterface
- $logger : LoggerInterface
- $request : Request|null
- $resolveResult : bool|HttpException|NetworkException|callable(): Array|null
- A Result can be resolved many times. This variable contains the last resolve result.
- $streamStarted : bool
- A flag that indicated that the body started being downloaded.
Methods
- __construct() : mixed
- __destruct() : mixed
- cancel() : void
- getContent() : string
- getHeaders() : array<string, array<int, string>>
- getStatusCode() : int
- info() : ResponseInterface, status: int}
- Returns info on the current request.
- resolve() : bool
- Make sure the actual request is executed.
- toArray() : array<string, mixed>
- toStream() : ResultStream
- wait() : iterable<string|int, self>
- Make sure all provided requests are executed.
- defineResolveStatus() : void
- In PHP < 7.4, a reference to the arguments is present in the stackTrace of the exception.
- getResolveStatus() : bool
Properties
$awsErrorFactory
private
AwsErrorFactoryInterface
$awsErrorFactory
$bodyDownloaded
A flag that indicated that the body have been downloaded.
private
bool
$bodyDownloaded
= false
$debug
private
bool
$debug
$didThrow
A flag that indicated that an exception has been thrown to the user.
private
bool
$didThrow
= false
$endpointCache
private
EndpointCache|null
$endpointCache
$exceptionMapping
private
array<string, HttpException>>
$exceptionMapping
$httpClient
private
HttpClientInterface
$httpClient
$httpResponse
private
ResponseInterface
$httpResponse
$logger
private
LoggerInterface
$logger
$request
private
Request|null
$request
$resolveResult
A Result can be resolved many times. This variable contains the last resolve result.
private
bool|HttpException|NetworkException|callable(): Array|null
$resolveResult
Null means that the result has never been resolved. Array contains material to create an exception.
$streamStarted
A flag that indicated that the body started being downloaded.
private
bool
$streamStarted
= false
Methods
__construct()
public
__construct(ResponseInterface $response, HttpClientInterface $httpClient, LoggerInterface $logger[, AwsErrorFactoryInterface|null $awsErrorFactory = null ][, EndpointCache|null $endpointCache = null ][, Request|null $request = null ][, bool $debug = false ][, array<string, HttpException>> $exceptionMapping = [] ]) : mixed
Parameters
- $response : ResponseInterface
- $httpClient : HttpClientInterface
- $logger : LoggerInterface
- $awsErrorFactory : AwsErrorFactoryInterface|null = null
- $endpointCache : EndpointCache|null = null
- $request : Request|null = null
- $debug : bool = false
- $exceptionMapping : array<string, HttpException>> = []
__destruct()
public
__destruct() : mixed
cancel()
public
cancel() : void
getContent()
public
getContent() : string
Tags
Return values
stringgetHeaders()
public
getHeaders() : array<string, array<int, string>>
Tags
Return values
array<string, array<int, string>>getStatusCode()
public
getStatusCode() : int
Return values
intinfo()
Returns info on the current request.
public
info() : ResponseInterface, status: int}
Return values
ResponseInterface, status: int}resolve()
Make sure the actual request is executed.
public
resolve([float|null $timeout = null ]) : bool
Parameters
- $timeout : float|null = null
-
Duration in seconds before aborting. When null wait until the end of execution. Using 0 means non-blocking
Tags
Return values
bool —whether the request is executed or not
toArray()
public
toArray() : array<string, mixed>
Tags
Return values
array<string, mixed>toStream()
public
toStream() : ResultStream
Tags
Return values
ResultStreamwait()
Make sure all provided requests are executed.
public
final static wait(array<string|int, self> $responses[, float|null $timeout = null ][, bool $downloadBody = false ]) : iterable<string|int, self>
Parameters
- $responses : array<string|int, self>
- $timeout : float|null = null
-
Duration in seconds before aborting. When null wait until the end of execution. Using 0 means non-blocking
- $downloadBody : bool = false
-
Wait until receiving the entire response body or only the first bytes
Tags
Return values
iterable<string|int, self>defineResolveStatus()
In PHP < 7.4, a reference to the arguments is present in the stackTrace of the exception.
private
defineResolveStatus() : void
This creates a Circular reference: Response -> resolveResult -> Exception -> stackTrace -> Response.
This mean, that calling unset($response)
does not call the __destruct
method and does not throw the
remaining exception present in resolveResult
. The __destruct
method will be called once the garbage collector
will detect the loop.
That's why this method does not creates exception here, but creates closure instead that will be resolved right
before throwing the exception.
getResolveStatus()
private
getResolveStatus() : bool