class CurlStreamingBody implements StreamInterface

internal  
 

Drive one transfer from the response consumer, including across coroutine handoff.

Constants

DEFAULT_READ_TIMEOUT

Properties

protected bool $attached
protected bool $completed
protected bool $closed
protected bool $exposed
protected bool $timedOut
protected int $position
protected string $pending
protected int $pendingOffset
protected ResponseInterface|null $completedResponse
protected TransferStats|null $completedStats
protected null|list<array<string, list<string>>|RequestInterface|ResponseInterface> $pendingTrailerArguments
protected RequestInterface $request

Methods

__construct(CurlStreamingHandler $handler, CurlFactoryInterface $factory, CurlStreamingConnection|null $connection, EasyHandle|null $easy, BufferStream $buffer, bool $paused, array $options, float $startedAt, float|null $headerDeadline, float $readTimeout)

Take ownership of a configured transfer and its bounded receive buffer.

ResponseInterface
response()

Receive the final headers and expose a caller-owned streaming body.

ResponseException
responseException(string $message, ResponseInterface $response, Throwable|null $previous = null, bool $timeout = false)

Create a transport failure that retains the received response.

string
read(int $length)

Read available bytes without waiting to fill the requested length.

void
advance()

Drive native I/O and settle a completed transfer once.

void
wait(float|null $idleDeadline, bool $headers = false)

Wait for network progress within the current phase's deadline.

void
reportStats(ResponseInterface|null $response, Throwable|null $error = null)

Report streaming statistics once, at the handler-return boundary.

void
detachTransfer()

Remove the active handle before returning its native connection cache.

void
close()

Close the stream and settle its transfer without waiting for more data.

mixed
detach()

Detach the body, which has no PHP stream resource to return.

int|null
getSize()

Get the unknown size of the incremental response body.

int
tell()

Get the number of bytes consumed by the caller.

bool
eof()

Determine whether the completed body has been consumed.

bool
isSeekable()

Determine whether the stream can seek.

void
seek(int $offset, int $whence = SEEK_SET)

Reject seeking on an incremental response.

void
rewind()

Reject rewinding an incremental response.

bool
isWritable()

Determine whether the response accepts writes.

int
write(string $string)

Reject writes to the response body.

bool
isReadable()

Determine whether the stream is open for reading.

string
getContents()

Read the remaining response body.

mixed
getMetadata(string|null $key = null)

Get metadata for the forward-only response stream.

string
__toString()

Read the remaining response body as a string.

__destruct()

Release a response abandoned by its consumer.

Details

at line 67
__construct(CurlStreamingHandler $handler, CurlFactoryInterface $factory, CurlStreamingConnection|null $connection, EasyHandle|null $easy, BufferStream $buffer, bool $paused, array $options, float $startedAt, float|null $headerDeadline, float $readTimeout)

Take ownership of a configured transfer and its bounded receive buffer.

Parameters

CurlStreamingHandler $handler
CurlFactoryInterface $factory
CurlStreamingConnection|null $connection
EasyHandle|null $easy
BufferStream $buffer
bool $paused
array $options
float $startedAt
float|null $headerDeadline
float $readTimeout

at line 85
ResponseInterface response()

Receive the final headers and expose a caller-owned streaming body.

Return Value

ResponseInterface

at line 181
protected ResponseException responseException(string $message, ResponseInterface $response, Throwable|null $previous = null, bool $timeout = false)

Create a transport failure that retains the received response.

Parameters

string $message
ResponseInterface $response
Throwable|null $previous
bool $timeout

Return Value

ResponseException

at line 191
string read(int $length)

Read available bytes without waiting to fill the requested length.

Parameters

int $length

Return Value

string

at line 261
protected void advance()

Drive native I/O and settle a completed transfer once.

Return Value

void

at line 352
protected void wait(float|null $idleDeadline, bool $headers = false)

Wait for network progress within the current phase's deadline.

Parameters

float|null $idleDeadline
bool $headers

Return Value

void

at line 390
protected void reportStats(ResponseInterface|null $response, Throwable|null $error = null)

Report streaming statistics once, at the handler-return boundary.

Parameters

ResponseInterface|null $response
Throwable|null $error

Return Value

void

at line 420
protected void detachTransfer()

Remove the active handle before returning its native connection cache.

Return Value

void

at line 443
void close()

Close the stream and settle its transfer without waiting for more data.

Return Value

void

at line 473
mixed detach()

Detach the body, which has no PHP stream resource to return.

Return Value

mixed

at line 483
int|null getSize()

Get the unknown size of the incremental response body.

Return Value

int|null

at line 491
int tell()

Get the number of bytes consumed by the caller.

Return Value

int

at line 499
bool eof()

Determine whether the completed body has been consumed.

Return Value

bool

at line 507
bool isSeekable()

Determine whether the stream can seek.

Return Value

bool

at line 515
void seek(int $offset, int $whence = SEEK_SET)

Reject seeking on an incremental response.

Parameters

int $offset
int $whence

Return Value

void

at line 524
void rewind()

Reject rewinding an incremental response.

Return Value

void

at line 533
bool isWritable()

Determine whether the response accepts writes.

Return Value

bool

at line 541
int write(string $string)

Reject writes to the response body.

Parameters

string $string

Return Value

int

at line 550
bool isReadable()

Determine whether the stream is open for reading.

Return Value

bool

at line 558
string getContents()

Read the remaining response body.

Return Value

string

at line 572
mixed getMetadata(string|null $key = null)

Get metadata for the forward-only response stream.

Parameters

string|null $key

Return Value

mixed

at line 582
string __toString()

Read the remaining response body as a string.

Return Value

string

at line 590
__destruct()

Release a response abandoned by its consumer.