Documentation

Stream extends AbstractClient
in package

HTTP stream client class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.1.0

Table of Contents

$context  : resource
Stream context
$contextOptions  : array<string|int, mixed>
Stream context options
$contextParams  : array<string|int, mixed>
Stream context parameters
$httpResponseHeaders  : array<string|int, mixed>
HTTP response headers
$method  : string
Method
$mode  : string
Stream mode
$request  : Request
Client request object
$resource  : resource
Client resource object
$response  : Response
Client response object
$url  : string
URL
__construct()  : mixed
Constructor
addContextOption()  : Stream
Add a context options
addContextParam()  : Stream
Add a context parameter
addRequestHeader()  : AbstractClient
Add request header
addRequestHeaders()  : AbstractClient
Add request headers
addResponseHeader()  : AbstractClient
Add response header
addResponseHeaders()  : AbstractClient
Add response headers
appendToUrl()  : AbstractClient
Append to the URL
createAsJson()  : AbstractClient
Create request as JSON
createAsXml()  : AbstractClient
Create request as XML
createContext()  : Stream
Create stream context
createMultipartForm()  : AbstractClient
Create request as a multipart form
createUrlEncodedForm()  : AbstractClient
Create request as a URL-encoded form
disconnect()  : void
Close the stream
getContext()  : resource
Get the context resource
getContextOption()  : mixed
Get a context option
getContextOptions()  : array<string|int, mixed>
Get the context options
getContextParam()  : mixed
Get a context parameter
getContextParams()  : array<string|int, mixed>
Get the context parameters
getField()  : mixed
Get a field
getFields()  : array<string|int, mixed>
Get all fields
getMethod()  : string
Get the method
getMode()  : string
Get the mode
getParsedResponse()  : mixed
Get the parsed response
getRequest()  : Request
Get the request object
getRequestBody()  : string
Get the request body
getRequestHeader()  : mixed
Get the request header
getRequestHeaders()  : array<string|int, mixed>
Get the request headers
getResource()  : resource
Get the resource
getResponse()  : Response
Get the response object
getResponseBody()  : string
Get the response body
getResponseCode()  : string
Get the response code
getResponseHeader()  : mixed
Get the response header
getResponseHeaders()  : array<string|int, mixed>
Get the response headers
getUrl()  : string
Get the URL
hasContextOption()  : bool
Determine if a context option has been set
hasContextParam()  : bool
Determine if a context parameter has been set
hasField()  : bool
Has field
hasFields()  : bool
Has fields
hasRequest()  : bool
Has request object
hasRequestHeader()  : bool
Has request header
hasRequestHeaders()  : bool
Has request headers
hasResource()  : bool
Determine whether or not resource is available
hasResponse()  : bool
Has response object
hasResponseHeader()  : bool
Has response header
hasResponseHeaders()  : bool
Has response headers
isJson()  : bool
Check if request is JSON
isMultipartForm()  : bool
Check if request is a multipart form
isUrlEncodedForm()  : bool
Check if request is a URL-encoded form
isXml()  : bool
Check if request is XML
open()  : Stream
Create and open stream resource
removeField()  : AbstractClient
Remove a field
removeFields()  : AbstractClient
Remove all fields
request()  : Request
Get the request object (alias method)
reset()  : Stream
Method to reset the client object
resource()  : resource
Get the resource (alias method)
response()  : Response
Get the response object (alias method)
send()  : void
Method to send the request and get the response
setContextOptions()  : Stream
Set the context options
setContextParams()  : Stream
Set the context parameters
setField()  : AbstractClient
Set a field
setFields()  : AbstractClient
Set all fields
setMethod()  : Stream
Set the method
setMode()  : Stream
Set the mode
setRequest()  : AbstractClient
Set the request object
setResponse()  : AbstractClient
Set the response object
setUrl()  : AbstractClient
Set the URL
stream()  : resource
Return stream resource (alias to $this->getResource())
throwError()  : void
Throw an exception upon an error.

Properties

$context

Stream context

protected resource $context = null

$contextOptions

Stream context options

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

$contextParams

Stream context parameters

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

$httpResponseHeaders

HTTP response headers

protected array<string|int, mixed> $httpResponseHeaders = null

$mode

Stream mode

protected string $mode = 'r'

$resource

Client resource object

protected resource $resource = null

Methods

__construct()

Constructor

public __construct([string $url = null ][, string $method = 'GET' ][, string $mode = 'r' ][, array<string|int, mixed> $options = [] ][, array<string|int, mixed> $params = [] ]) : mixed

Instantiate the stream object

Parameters
$url : string = null
$method : string = 'GET'
$mode : string = 'r'
$options : array<string|int, mixed> = []
$params : array<string|int, mixed> = []
Return values
mixed

addContextOption()

Add a context options

public addContextOption(string $name, mixed $option) : Stream
Parameters
$name : string
$option : mixed
Return values
Stream

addContextParam()

Add a context parameter

public addContextParam(string $name, mixed $param) : Stream
Parameters
$name : string
$param : mixed
Return values
Stream

createContext()

Create stream context

public createContext() : Stream
Return values
Stream

disconnect()

Close the stream

public disconnect() : void
Return values
void

getContext()

Get the context resource

public getContext() : resource
Return values
resource

getContextOption()

Get a context option

public getContextOption(string $name) : mixed
Parameters
$name : string
Return values
mixed

getContextOptions()

Get the context options

public getContextOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getContextParam()

Get a context parameter

public getContextParam(string $name) : mixed
Parameters
$name : string
Return values
mixed

getContextParams()

Get the context parameters

public getContextParams() : array<string|int, mixed>
Return values
array<string|int, mixed>

getField()

Get a field

public getField(string $name) : mixed
Parameters
$name : string
Return values
mixed

getFields()

Get all fields

public getFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMethod()

Get the method

public getMethod() : string
Return values
string

getMode()

Get the mode

public getMode() : string
Return values
string

getParsedResponse()

Get the parsed response

public getParsedResponse() : mixed
Return values
mixed

getRequestBody()

Get the request body

public getRequestBody() : string
Return values
string

getRequestHeader()

Get the request header

public getRequestHeader(string $name) : mixed
Parameters
$name : string
Return values
mixed

getRequestHeaders()

Get the request headers

public getRequestHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getResource()

Get the resource

public getResource() : resource
Return values
resource

getResponseBody()

Get the response body

public getResponseBody() : string
Return values
string

getResponseCode()

Get the response code

public getResponseCode() : string
Return values
string

getResponseHeader()

Get the response header

public getResponseHeader(string $name) : mixed
Parameters
$name : string
Return values
mixed

getResponseHeaders()

Get the response headers

public getResponseHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getUrl()

Get the URL

public getUrl() : string
Return values
string

hasContextOption()

Determine if a context option has been set

public hasContextOption(string $name) : bool
Parameters
$name : string
Return values
bool

hasContextParam()

Determine if a context parameter has been set

public hasContextParam(string $name) : bool
Parameters
$name : string
Return values
bool

hasField()

Has field

public hasField(string $name) : bool
Parameters
$name : string
Return values
bool

hasFields()

Has fields

public hasFields() : bool
Return values
bool

hasRequest()

Has request object

public hasRequest() : bool
Return values
bool

hasRequestHeader()

Has request header

public hasRequestHeader(string $name) : bool
Parameters
$name : string
Return values
bool

hasRequestHeaders()

Has request headers

public hasRequestHeaders() : bool
Return values
bool

hasResource()

Determine whether or not resource is available

public hasResource() : bool
Return values
bool

hasResponse()

Has response object

public hasResponse() : bool
Return values
bool

hasResponseHeader()

Has response header

public hasResponseHeader(string $name) : bool
Parameters
$name : string
Return values
bool

hasResponseHeaders()

Has response headers

public hasResponseHeaders() : bool
Return values
bool

isJson()

Check if request is JSON

public isJson() : bool
Return values
bool

isMultipartForm()

Check if request is a multipart form

public isMultipartForm() : bool
Return values
bool

isUrlEncodedForm()

Check if request is a URL-encoded form

public isUrlEncodedForm() : bool
Return values
bool

isXml()

Check if request is XML

public isXml() : bool
Return values
bool

resource()

Get the resource (alias method)

public resource() : resource
Return values
resource

send()

Method to send the request and get the response

public send() : void
Return values
void

setContextOptions()

Set the context options

public setContextOptions(array<string|int, mixed> $options) : Stream
Parameters
$options : array<string|int, mixed>
Return values
Stream

setContextParams()

Set the context parameters

public setContextParams(array<string|int, mixed> $params) : Stream
Parameters
$params : array<string|int, mixed>
Return values
Stream

setMethod()

Set the method

public setMethod(string $method[, bool $strict = true ]) : Stream
Parameters
$method : string
$strict : bool = true
Tags
throws
Exception
Return values
Stream

setMode()

Set the mode

public setMode(string $mode) : Stream
Parameters
$mode : string
Return values
Stream

stream()

Return stream resource (alias to $this->getResource())

public stream() : resource
Return values
resource

throwError()

Throw an exception upon an error.

public throwError(string $error) : void
Parameters
$error : string
Tags
throws
Exception
Return values
void

Search results