Documentation

Request extends AbstractRequest
in package

HTTP client request 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

$body  : Body
Body
$fields  : array<string|int, mixed>
Fields (form fields and files) $fields = [ 'username' => 'admin' 'file1' => [ 'filename' => __DIR__ . '/path/to/file.txt', 'contentType' => 'text/plain' ], 'file2' => [ 'filename' => 'test.pdf', 'contentType' => 'application/pdf', 'contents' => file_get_contents(__DIR__ . '/path/to/test.pdf' ] ]
$filters  : array<string|int, mixed>
Form filters
$formType  : string
Request form type
$headers  : array<string|int, mixed>
Headers
$query  : string
Request query
__construct()  : mixed
Constructor
__get()  : mixed
Magic method to get either the headers or body
addFilter()  : FilterableTrait
Add filter
addFilters()  : FilterableTrait
Add filters
addHeader()  : AbstractHttp
Add a header
addHeaders()  : AbstractHttp
Add all headers
clearFilters()  : FilterableTrait
Clear filters
createAsJson()  : Request
Create request as JSON
createAsXml()  : Request
Create request as XML
createMultipartForm()  : Request
Create request as a multipart form
createUrlEncodedForm()  : Request
Create request as a URL-encoded form
decodeBodyContent()  : Body
Decode the body
filter()  : array<string|int, mixed>
Filter values
filterAll()  : array<string|int, mixed>
Filter all values, ignoring excludes
getBody()  : Body
Get the body
getBodyContent()  : mixed
Get body content
getField()  : mixed
Get a field
getFields()  : array<string|int, mixed>
Get all field
getFilters()  : array<string|int, mixed>
Get filters
getFormType()  : string
Get form type
getHeader()  : mixed
Get a header
getHeaders()  : array<string|int, mixed>
Get all headers
getHeadersAsArray()  : array<string|int, mixed>
Get all header values as associative array
getHeadersAsString()  : string
Get all header values formatted string
getHeaderValue()  : mixed
Get header value
getQuery()  : string
Get HTTP query
getQueryLength()  : int
Get HTTP query length
hasBody()  : bool
Has a body
hasBodyContent()  : bool
Has body content
hasField()  : bool
Has field
hasFields()  : bool
Has fields
hasFilters()  : bool
Has filters
hasHeader()  : bool
Has a header
hasHeaders()  : bool
Determine if there are headers
hasQuery()  : string
Is HTTP query prepared
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
prepareQuery()  : string
Prepare the HTTP query
removeBody()  : AbstractHttp
Remove the body
removeField()  : Request
Remove a field
removeFields()  : Request
Remove all fields
removeHeader()  : AbstractHttp
Remove a header
removeHeaders()  : AbstractHttp
Remove all headers
setBody()  : AbstractHttp
Set the body
setField()  : Request
Set a field
setFields()  : Request
Set all fields

Properties

$fields

Fields (form fields and files) $fields = [ 'username' => 'admin' 'file1' => [ 'filename' => __DIR__ . '/path/to/file.txt', 'contentType' => 'text/plain' ], 'file2' => [ 'filename' => 'test.pdf', 'contentType' => 'application/pdf', 'contents' => file_get_contents(__DIR__ . '/path/to/test.pdf' ] ]

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

$filters

Form filters

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

$formType

Request form type

protected string $formType = null

$headers

Headers

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

$query

Request query

protected string $query = null

Methods

__construct()

Constructor

public __construct([mixed $filters = null ]) : mixed

Instantiate the request object

Parameters
$filters : mixed = null
Return values
mixed

__get()

Magic method to get either the headers or body

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

createMultipartForm()

Create request as a multipart form

public createMultipartForm() : Request
Return values
Request

createUrlEncodedForm()

Create request as a URL-encoded form

public createUrlEncodedForm() : Request
Return values
Request

decodeBodyContent()

Decode the body

public decodeBodyContent([string $body = null ]) : Body
Parameters
$body : string = null
Return values
Body

filter()

Filter values

public abstract filter(mixed $values) : array<string|int, mixed>
Parameters
$values : mixed
Return values
array<string|int, mixed>

filterAll()

Filter all values, ignoring excludes

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

getBodyContent()

Get body content

public getBodyContent() : mixed
Return values
mixed

getField()

Get a field

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

getFields()

Get all field

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

getFilters()

Get filters

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

getFormType()

Get form type

public getFormType() : string
Return values
string

getHeader()

Get a header

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

getHeaders()

Get all headers

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

getHeadersAsArray()

Get all header values as associative array

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

getHeadersAsString()

Get all header values formatted string

public getHeadersAsString([string $status = null ][, string $eol = " " ]) : string
Parameters
$status : string = null
$eol : string = " "
Return values
string

getHeaderValue()

Get header value

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

getQuery()

Get HTTP query

public getQuery() : string
Return values
string

getQueryLength()

Get HTTP query length

public getQueryLength([bool $mb = false ]) : int
Parameters
$mb : bool = false
Return values
int

hasBody()

Has a body

public hasBody() : bool
Return values
bool

hasBodyContent()

Has body content

public hasBodyContent() : bool
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

hasFilters()

Has filters

public hasFilters() : bool
Return values
bool

hasHeader()

Has a header

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

hasHeaders()

Determine if there are headers

public hasHeaders() : bool
Return values
bool

hasQuery()

Is HTTP query prepared

public hasQuery() : string
Return values
string

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

prepareQuery()

Prepare the HTTP query

public prepareQuery() : string
Return values
string

removeField()

Remove a field

public removeField(string $name) : Request
Parameters
$name : string
Return values
Request

setField()

Set a field

public setField(string $name, mixed $value) : Request
Parameters
$name : string
$value : mixed
Return values
Request

setFields()

Set all fields

public setFields(array<string|int, mixed> $fields) : Request
Parameters
$fields : array<string|int, mixed>
Return values
Request

Search results