HumHub Documentation (unofficial)

Stream extends Response
in package

Represents an HTTP response message as PHP stream resource

Table of Contents

Constants

STATUS_CODE_100  = 100
STATUS_CODE_101  = 101
STATUS_CODE_102  = 102
STATUS_CODE_200  = 200
STATUS_CODE_201  = 201
STATUS_CODE_202  = 202
STATUS_CODE_203  = 203
STATUS_CODE_204  = 204
STATUS_CODE_205  = 205
STATUS_CODE_206  = 206
STATUS_CODE_207  = 207
STATUS_CODE_208  = 208
STATUS_CODE_226  = 226
STATUS_CODE_300  = 300
STATUS_CODE_301  = 301
STATUS_CODE_302  = 302
STATUS_CODE_303  = 303
STATUS_CODE_304  = 304
STATUS_CODE_305  = 305
STATUS_CODE_306  = 306
STATUS_CODE_307  = 307
STATUS_CODE_308  = 308
STATUS_CODE_400  = 400
STATUS_CODE_401  = 401
STATUS_CODE_402  = 402
STATUS_CODE_403  = 403
STATUS_CODE_404  = 404
STATUS_CODE_405  = 405
STATUS_CODE_406  = 406
STATUS_CODE_407  = 407
STATUS_CODE_408  = 408
STATUS_CODE_409  = 409
STATUS_CODE_410  = 410
STATUS_CODE_411  = 411
STATUS_CODE_412  = 412
STATUS_CODE_413  = 413
STATUS_CODE_414  = 414
STATUS_CODE_415  = 415
STATUS_CODE_416  = 416
STATUS_CODE_417  = 417
STATUS_CODE_418  = 418
STATUS_CODE_422  = 422
STATUS_CODE_423  = 423
STATUS_CODE_424  = 424
STATUS_CODE_425  = 425
STATUS_CODE_426  = 426
STATUS_CODE_428  = 428
STATUS_CODE_429  = 429
STATUS_CODE_431  = 431
STATUS_CODE_444  = 444
STATUS_CODE_451  = 451
STATUS_CODE_499  = 499
STATUS_CODE_500  = 500
STATUS_CODE_501  = 501
STATUS_CODE_502  = 502
STATUS_CODE_503  = 503
STATUS_CODE_504  = 504
STATUS_CODE_505  = 505
STATUS_CODE_506  = 506
STATUS_CODE_507  = 507
STATUS_CODE_508  = 508
STATUS_CODE_510  = 510
STATUS_CODE_511  = 511
STATUS_CODE_599  = 599
STATUS_CODE_CUSTOM  = 0
VERSION_10  = '1.0'
VERSION_11  = '1.1'
VERSION_2  = '2'

Properties

$cleanup  : bool
Should we clean up the stream file when this response is closed?
$content  : mixed
$contentLength  : int
The Content-Length value, if set
$contentStreamed  : int
The portion of the body that has already been streamed
$headers  : Headers|null
$metadata  : array<string|int, mixed>
$reasonPhrase  : string|null
$recommendedReasonPhrases  : array<string|int, mixed>
$statusCode  : int
$stream  : resource
Response as stream
$streamName  : string
The name of the file containing the stream
$version  : string

Methods

__destruct()  : mixed
Destructor
__toString()  : string
Allow PHP casting of this object
fromStream()  : $this
Create a new Laminas\Http\Response\Stream object from a stream
fromString()  : static
Populate object from string
getBody()  : string
Get the response body as string
getCleanup()  : bool
Get the cleanup trigger
getContent()  : mixed
Get message content
getContentLength()  : int|null
Get content length
getCookie()  : array<string|int, SetCookie>
getHeaders()  : Headers
Return the header container responsible for headers
getMetadata()  : mixed
Retrieve all metadata or a single metadatum as specified by key
getRawBody()  : string
Get the raw response body (as transferred "on wire") as string
getReasonPhrase()  : string
Get HTTP status message
getStatusCode()  : int
Retrieve HTTP status code
getStream()  : resource
Get the response as stream
getStreamName()  : string
Get file name associated with the stream
getVersion()  : string
Return the HTTP version for this request
isClientError()  : bool
Does the status code indicate a client error?
isForbidden()  : bool
Is the request forbidden due to ACLs?
isGone()  : bool
Does the status code indicate the resource is gone?
isInformational()  : bool
Is the current status "informational"?
isNotFound()  : bool
Does the status code indicate the resource is not found?
isOk()  : bool
Do we have a normal, OK response?
isRedirect()  : bool
Do we have a redirect?
isServerError()  : bool
Does the status code reflect a server error?
isSuccess()  : bool
Was the response successful?
renderStatusLine()  : string
Render the status line header
setCleanup()  : mixed
Set the cleanup trigger
setContent()  : Message
Set message content
setContentLength()  : mixed
Set content length
setCustomStatusCode()  : $this
Set custom HTTP status code
setHeaders()  : $this
Provide an alternate Parameter Container implementation for headers in this object, (this is NOT the primary API for value setting, for that see getHeaders())
setMetadata()  : Message
Set message metadata
setReasonPhrase()  : $this
setStatusCode()  : $this
Set HTTP status code and (optionally) message
setStream()  : $this
Set the response stream
setStreamName()  : $this
Set file name associated with the stream
setVersion()  : $this
Set the HTTP version for this object, one of 1.0, 1.1 or 2 (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11, AbstractMessage::VERSION_2)
toString()  : string
Render entire response as HTTP response string
decodeChunkedBody()  : string
Decode a "chunked" transfer-encoded body and return the decoded text
decodeDeflate()  : string
Decode a zlib deflated message (when Content-encoding = deflate)
decodeGzip()  : string
Decode a gzip encoded message (when Content-encoding = gzip)
parseStatusLine()  : mixed
readStream()  : string
Read stream content and return it as string
saveStatusCode()  : $this
Assign status code

Constants

STATUS_CODE_100

public mixed STATUS_CODE_100 = 100

STATUS_CODE_101

public mixed STATUS_CODE_101 = 101

STATUS_CODE_102

public mixed STATUS_CODE_102 = 102

STATUS_CODE_200

public mixed STATUS_CODE_200 = 200

STATUS_CODE_201

public mixed STATUS_CODE_201 = 201

STATUS_CODE_202

public mixed STATUS_CODE_202 = 202

STATUS_CODE_203

public mixed STATUS_CODE_203 = 203

STATUS_CODE_204

public mixed STATUS_CODE_204 = 204

STATUS_CODE_205

public mixed STATUS_CODE_205 = 205

STATUS_CODE_206

public mixed STATUS_CODE_206 = 206

STATUS_CODE_207

public mixed STATUS_CODE_207 = 207

STATUS_CODE_208

public mixed STATUS_CODE_208 = 208

STATUS_CODE_226

public mixed STATUS_CODE_226 = 226

STATUS_CODE_300

public mixed STATUS_CODE_300 = 300

STATUS_CODE_301

public mixed STATUS_CODE_301 = 301

STATUS_CODE_302

public mixed STATUS_CODE_302 = 302

STATUS_CODE_303

public mixed STATUS_CODE_303 = 303

STATUS_CODE_304

public mixed STATUS_CODE_304 = 304

STATUS_CODE_305

public mixed STATUS_CODE_305 = 305

STATUS_CODE_306

public mixed STATUS_CODE_306 = 306

STATUS_CODE_307

public mixed STATUS_CODE_307 = 307

STATUS_CODE_308

public mixed STATUS_CODE_308 = 308

STATUS_CODE_400

public mixed STATUS_CODE_400 = 400

STATUS_CODE_401

public mixed STATUS_CODE_401 = 401

STATUS_CODE_402

public mixed STATUS_CODE_402 = 402

STATUS_CODE_403

public mixed STATUS_CODE_403 = 403

STATUS_CODE_404

public mixed STATUS_CODE_404 = 404

STATUS_CODE_405

public mixed STATUS_CODE_405 = 405

STATUS_CODE_406

public mixed STATUS_CODE_406 = 406

STATUS_CODE_407

public mixed STATUS_CODE_407 = 407

STATUS_CODE_408

public mixed STATUS_CODE_408 = 408

STATUS_CODE_409

public mixed STATUS_CODE_409 = 409

STATUS_CODE_410

public mixed STATUS_CODE_410 = 410

STATUS_CODE_411

public mixed STATUS_CODE_411 = 411

STATUS_CODE_412

public mixed STATUS_CODE_412 = 412

STATUS_CODE_413

public mixed STATUS_CODE_413 = 413

STATUS_CODE_414

public mixed STATUS_CODE_414 = 414

STATUS_CODE_415

public mixed STATUS_CODE_415 = 415

STATUS_CODE_416

public mixed STATUS_CODE_416 = 416

STATUS_CODE_417

public mixed STATUS_CODE_417 = 417

STATUS_CODE_418

public mixed STATUS_CODE_418 = 418

STATUS_CODE_422

public mixed STATUS_CODE_422 = 422

STATUS_CODE_423

public mixed STATUS_CODE_423 = 423

STATUS_CODE_424

public mixed STATUS_CODE_424 = 424

STATUS_CODE_425

public mixed STATUS_CODE_425 = 425

STATUS_CODE_426

public mixed STATUS_CODE_426 = 426

STATUS_CODE_428

public mixed STATUS_CODE_428 = 428

STATUS_CODE_429

public mixed STATUS_CODE_429 = 429

STATUS_CODE_431

public mixed STATUS_CODE_431 = 431

STATUS_CODE_444

public mixed STATUS_CODE_444 = 444

STATUS_CODE_451

public mixed STATUS_CODE_451 = 451

STATUS_CODE_499

public mixed STATUS_CODE_499 = 499

STATUS_CODE_500

public mixed STATUS_CODE_500 = 500

STATUS_CODE_501

public mixed STATUS_CODE_501 = 501

STATUS_CODE_502

public mixed STATUS_CODE_502 = 502

STATUS_CODE_503

public mixed STATUS_CODE_503 = 503

STATUS_CODE_504

public mixed STATUS_CODE_504 = 504

STATUS_CODE_505

public mixed STATUS_CODE_505 = 505

STATUS_CODE_506

public mixed STATUS_CODE_506 = 506

STATUS_CODE_507

public mixed STATUS_CODE_507 = 507

STATUS_CODE_508

public mixed STATUS_CODE_508 = 508

STATUS_CODE_510

public mixed STATUS_CODE_510 = 510

STATUS_CODE_511

public mixed STATUS_CODE_511 = 511

STATUS_CODE_599

public mixed STATUS_CODE_599 = 599

STATUS_CODE_CUSTOM

public mixed STATUS_CODE_CUSTOM = 0

Properties

$cleanup

Should we clean up the stream file when this response is closed?

protected bool $cleanup

$content

protected mixed $content = ''

$contentLength

The Content-Length value, if set

protected int $contentLength

$contentStreamed

The portion of the body that has already been streamed

protected int $contentStreamed = 0

$metadata

protected array<string|int, mixed> $metadata = []

$reasonPhrase

protected string|null $reasonPhrase

Null means it will be looked up from the $reasonPhrase list above

$recommendedReasonPhrases

protected array<string|int, mixed> $recommendedReasonPhrases = [ // INFORMATIONAL CODES 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', // SUCCESS CODES 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-status', 208 => 'Already Reported', 226 => 'IM Used', // REDIRECTION CODES 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Switch Proxy', // Deprecated 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', // CLIENT ERROR 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Content Too Large', 414 => 'URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 422 => 'Unprocessable Content', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Too Early', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 444 => 'Connection Closed Without Response', 451 => 'Unavailable For Legal Reasons', 499 => 'Client Closed Request', // SERVER ERROR 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version not supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended', 511 => 'Network Authentication Required', 599 => 'Network Connect Timeout Error', ]

Recommended Reason Phrases

$statusCode

protected int $statusCode = 200

Status code

$stream

Response as stream

protected resource $stream

$streamName

The name of the file containing the stream

protected string $streamName

Will be empty if stream is not file-based.

Methods

__destruct()

Destructor

public __destruct() : mixed

__toString()

Allow PHP casting of this object

public __toString() : string
Return values
string

fromStream()

Create a new Laminas\Http\Response\Stream object from a stream

public static fromStream(string $responseString, resource $stream) : $this
Parameters
$responseString : string
$stream : resource
Tags
throws
InvalidArgumentException
throws
OutOfRangeException
Return values
$this

fromString()

Populate object from string

public static fromString(string $string) : static
Parameters
$string : string
Tags
throws
InvalidArgumentException
Return values
static

getBody()

Get the response body as string

public getBody() : string

This method returns the body of the HTTP response (the content), as it should be in it's readable version - that is, after decoding it (if it was decoded), deflating it (if it was gzip compressed), etc.

If you want to get the raw body (as transferred on wire) use $this->getRawBody() instead.

Return values
string

getCleanup()

Get the cleanup trigger

public getCleanup() : bool
Return values
bool

getContent()

Get message content

public getContent() : mixed

getContentLength()

Get content length

public getContentLength() : int|null
Return values
int|null

getMetadata()

Retrieve all metadata or a single metadatum as specified by key

public getMetadata([null|string|int $key = null ][, null|mixed $default = null ]) : mixed
Parameters
$key : null|string|int = null
$default : null|mixed = null
Tags
throws
InvalidArgumentException

getRawBody()

Get the raw response body (as transferred "on wire") as string

public getRawBody() : string

If the body is encoded (with Transfer-Encoding, not content-encoding - IE "chunked" body), gzip compressed, etc. it will not be decoded.

Return values
string

getReasonPhrase()

Get HTTP status message

public getReasonPhrase() : string
Return values
string

getStatusCode()

Retrieve HTTP status code

public getStatusCode() : int
Return values
int

getStream()

Get the response as stream

public getStream() : resource
Return values
resource

getStreamName()

Get file name associated with the stream

public getStreamName() : string
Return values
string

getVersion()

Return the HTTP version for this request

public getVersion() : string
Return values
string

isClientError()

Does the status code indicate a client error?

public isClientError() : bool
Return values
bool

isForbidden()

Is the request forbidden due to ACLs?

public isForbidden() : bool
Return values
bool

isGone()

Does the status code indicate the resource is gone?

public isGone() : bool
Return values
bool

isInformational()

Is the current status "informational"?

public isInformational() : bool
Return values
bool

isNotFound()

Does the status code indicate the resource is not found?

public isNotFound() : bool
Return values
bool

isOk()

Do we have a normal, OK response?

public isOk() : bool
Return values
bool

isRedirect()

Do we have a redirect?

public isRedirect() : bool
Return values
bool

isServerError()

Does the status code reflect a server error?

public isServerError() : bool
Return values
bool

isSuccess()

Was the response successful?

public isSuccess() : bool
Return values
bool

renderStatusLine()

Render the status line header

public renderStatusLine() : string
Return values
string

setCleanup()

Set the cleanup trigger

public setCleanup([bool $cleanup = true ]) : mixed
Parameters
$cleanup : bool = true

setContent()

Set message content

public setContent(mixed $value) : Message
Parameters
$value : mixed
Return values
Message

setContentLength()

Set content length

public setContentLength([int $contentLength = null ]) : mixed
Parameters
$contentLength : int = null

setCustomStatusCode()

Set custom HTTP status code

public setCustomStatusCode(int $code) : $this
Parameters
$code : int
Tags
throws
InvalidArgumentException
Return values
$this

setHeaders()

Provide an alternate Parameter Container implementation for headers in this object, (this is NOT the primary API for value setting, for that see getHeaders())

public setHeaders(Headers $headers) : $this
Parameters
$headers : Headers
Tags
see
getHeaders()
Return values
$this

setMetadata()

Set message metadata

public setMetadata(string|int|array<string|int, mixed>|Traversable $spec[, mixed $value = null ]) : Message

Non-destructive setting of message metadata; always adds to the metadata, never overwrites the entire metadata container.

Parameters
$spec : string|int|array<string|int, mixed>|Traversable
$value : mixed = null
Tags
throws
InvalidArgumentException
Return values
Message

setReasonPhrase()

public setReasonPhrase(string $reasonPhrase) : $this
Parameters
$reasonPhrase : string
Return values
$this

setStatusCode()

Set HTTP status code and (optionally) message

public setStatusCode(int $code) : $this
Parameters
$code : int
Tags
throws
InvalidArgumentException
Return values
$this

setStream()

Set the response stream

public setStream(resource $stream) : $this
Parameters
$stream : resource
Return values
$this

setStreamName()

Set file name associated with the stream

public setStreamName(string $streamName) : $this
Parameters
$streamName : string

Name to set

Return values
$this

setVersion()

Set the HTTP version for this object, one of 1.0, 1.1 or 2 (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11, AbstractMessage::VERSION_2)

public setVersion(string $version) : $this
Parameters
$version : string

(Must be 1.0, 1.1 or 2)

Tags
throws
InvalidArgumentException
Return values
$this

toString()

Render entire response as HTTP response string

public toString() : string
Return values
string

decodeChunkedBody()

Decode a "chunked" transfer-encoded body and return the decoded text

protected decodeChunkedBody(string $body) : string
Parameters
$body : string
Tags
throws
RuntimeException
Return values
string

decodeDeflate()

Decode a zlib deflated message (when Content-encoding = deflate)

protected decodeDeflate(string $body) : string

Currently requires PHP with zlib support

Parameters
$body : string
Tags
throws
RuntimeException
Return values
string

decodeGzip()

Decode a gzip encoded message (when Content-encoding = gzip)

protected decodeGzip(string $body) : string

Currently requires PHP with zlib support

Parameters
$body : string
Tags
throws
RuntimeException
Return values
string

readStream()

Read stream content and return it as string

protected readStream() : string

Function reads the remainder of the body from the stream and closes the stream.

Return values
string

saveStatusCode()

Assign status code

protected saveStatusCode(int $code) : $this
Parameters
$code : int
Return values
$this

        
On this page

Search results