class HttpRequest (View source)

Constants

METH_GET

METH_HEAD

METH_POST

METH_PUT

METH_DELETE

METH_OPTIONS

METH_TRACE

METH_CONNECT

METH_PROPFIND

METH_PROPPATCH

METH_MKCOL

METH_COPY

METH_MOVE

METH_LOCK

METH_UNLOCK

METH_VERSION_CONTROL

METH_REPORT

METH_CHECKOUT

METH_CHECKIN

METH_UNCHECKOUT

METH_MKWORKSPACE

METH_UPDATE

METH_LABEL

METH_MERGE

METH_BASELINE_CONTROL

METH_MKACTIVITY

METH_ACL

VERSION_1_0

VERSION_1_1

VERSION_NONE

VERSION_ANY

SSL_VERSION_TLSv1

SSL_VERSION_SSLv2

SSL_VERSION_SSLv3

SSL_VERSION_ANY

IPRESOLVE_V4

IPRESOLVE_V6

IPRESOLVE_ANY

AUTH_BASIC

AUTH_DIGEST

AUTH_NTLM

AUTH_GSSNEG

AUTH_ANY

PROXY_SOCKS4

PROXY_SOCKS5

PROXY_HTTP

Properties

$recordHistory

Methods

__construct(string $url = null, int $request_method = null, array|null $options = null)

(PECL pecl_http >= 0.10.0)
HttpRequest constructor

bool
setOptions(array|null $options = null)

(PECL pecl_http >= 0.10.0)
Set options

array
getOptions()

(PECL pecl_http >= 0.10.0)
Get options

bool
setSslOptions(array|null $options = null)

(PECL pecl_http >= 0.10.0)
Set ssl options

array
getSslOptions()

(PECL pecl_http >= 0.10.0)
Get ssl options

bool
addSslOptions(array $option)

(PECL pecl_http >= 0.12.0)
Add ssl options

bool
addHeaders(array $headers)

(PECL pecl_http >= 0.10.0)
Add headers

array
getHeaders()

(PECL pecl_http >= 0.10.0)
Get headers

bool
setHeaders(array|null $headers = null)

(PECL pecl_http >= 0.12.0)
Set headers

bool
addCookies(array $cookies)

(PECL pecl_http >= 0.10.0)
Add cookies

array
getCookies()

(PECL pecl_http >= 0.10.0)
Get cookies

bool
setCookies(array|null $cookies = null)

(PECL pecl_http >= 0.12.0)
Set cookies

bool
enableCookies()

(PECL pecl_http >= 1.0.0)
Enable cookies

bool
resetCookies(bool $session_only = null)

(PECL pecl_http >= 1.0.0)
Reset cookies

flushCookies()

No description

bool
setMethod(int $request_method)

(PECL pecl_http >= 0.10.0)
Set method

int
getMethod()

(PECL pecl_http >= 0.10.0)
Get method

bool
setUrl(string $url)

(PECL pecl_http >= 0.10.0)
Set URL

string
getUrl()

(PECL pecl_http >= 0.10.0)
Get url

bool
setContentType(string $content_type)

(PECL pecl_http >= 0.10.0)
Set content type

string
getContentType()

(PECL pecl_http >= 0.10.0)
Get content type

bool
setQueryData(mixed $query_data)

(PECL pecl_http >= 0.10.0)
Set query data

string
getQueryData()

(PECL pecl_http >= 0.10.0)
Get query data

bool
addQueryData(array $query_params)

(PECL pecl_http >= 0.10.0)
Add query data

bool
setPostFields(array $post_data)

(PECL pecl_http >= 0.10.0)
Set post fields

array
getPostFields()

(PECL pecl_http >= 0.10.0)
Get post fields

bool
addPostFields(array $post_data)

(PECL pecl_http >= 0.10.0)
Add post fields

setBody($request_body_data)

No description

getBody()

No description

addBody($request_body_data)

No description

bool
setRawPostData(string $raw_post_data = null)

(PECL pecl_http 0.14.0-1.4.1)
Set raw post data

string
getRawPostData()

(PECL pecl_http 0.14.0-1.4.1)
Get raw post data

bool
addRawPostData(string $raw_post_data)

(PECL pecl_http 0.14.0-1.4.1)
Add raw post data

bool
setPostFiles(array $post_files)

(PECL pecl_http >= 0.10.0)
Set post files

bool
addPostFile(string $name, string $file, string $content_type = null)

(PECL pecl_http >= 0.10.0)
Add post file

array
getPostFiles()

(PECL pecl_http >= 0.10.0)
Get post files

bool
setPutFile(string $file = null)

(PECL pecl_http >= 0.10.0)
Set put file

string
getPutFile()

(PECL pecl_http >= 0.10.0)
Get put file

bool
setPutData(string $put_data = null)

(PECL pecl_http >= 0.25.0)
Set put data

string
getPutData()

(PECL pecl_http >= 0.25.0)
Get put data

bool
addPutData(string $put_data)

(PECL pecl_http >= 0.25.0)
Add put data

send()

(PECL pecl_http >= 0.10.0)
Send request

array
getResponseData()

(PECL pecl_http >= 0.10.0)
Get response data

mixed
getResponseHeader(string $name = null)

(PECL pecl_http >= 0.10.0)
Get response header(s)

getResponseCookies(int $flags = null, array|null $allowed_extras = null)

(PECL pecl_http >= 0.23.0)
Get response cookie(s)

int
getResponseCode()

(PECL pecl_http >= 0.10.0)
Get response code

string
getResponseStatus()

(PECL pecl_http >= 0.23.0)
Get response status

string
getResponseBody()

(PECL pecl_http >= 0.10.0)
Get response body

mixed
getResponseInfo(string $name = null)

(PECL pecl_http >= 0.10.0)
Get response info

getResponseMessage()

(PECL pecl_http >= 0.10.0)
Get response message

string
getRawResponseMessage()

(PECL pecl_http >= 0.21.0)
Get raw response message

getRequestMessage()

(PECL pecl_http >= 0.11.0)
Get request message

string
getRawRequestMessage()

(PECL pecl_http >= 0.21.0)
Get raw request message

getHistory()

(PECL pecl_http >= 0.15.0)
Get history

void
clearHistory()

(PECL pecl_http >= 0.15.0)
Clear history

static 
factory($url, $method, $options, $class_name)

No description

static 
get($url, $options, $info)

No description

static 
head($url, $options, $info)

No description

static 
postData($url, $data, $options, $info)

No description

static 
postFields($url, $data, $options, $info)

No description

static 
putData($url, $data, $options, $info)

No description

static 
putFile($url, $file, $options, $info)

No description

static 
putStream($url, $stream, $options, $info)

No description

static 
methodRegister($method_name)

No description

static 
methodUnregister($method)

No description

static 
methodName($method_id)

No description

static 
methodExists($method)

No description

static 
encodeBody($fields, $files)

No description

Details

__construct(string $url = null, int $request_method = null, array|null $options = null)

(PECL pecl_http >= 0.10.0)
HttpRequest constructor

Parameters

string $url

[optional]

the target request url

int $request_method

[optional]

the request method to use

array|null $options

[optional]

an associative array with request options

bool setOptions(array|null $options = null)

(PECL pecl_http >= 0.10.0)
Set options

Parameters

array|null $options

[optional]

an associative array, which values will overwrite the currently set request options; if empty or omitted, the options of the HttpRequest object will be reset

Return Value

bool

true on success or false on failure.

array getOptions()

(PECL pecl_http >= 0.10.0)
Get options

Return Value

array

an associative array containing currently set options.

bool setSslOptions(array|null $options = null)

(PECL pecl_http >= 0.10.0)
Set ssl options

Parameters

array|null $options

[optional]

an associative array containing any SSL specific options; if empty or omitted, the SSL options will be reset

Return Value

bool

true on success or false on failure.

array getSslOptions()

(PECL pecl_http >= 0.10.0)
Get ssl options

Return Value

array

an associative array containing any previously set SSL options.

bool addSslOptions(array $option)

(PECL pecl_http >= 0.12.0)
Add ssl options

Parameters

array $option

an associative array as parameter containing additional SSL specific options

Return Value

bool

true on success or false on failure.

bool addHeaders(array $headers)

(PECL pecl_http >= 0.10.0)
Add headers

Parameters

array $headers

an associative array as parameter containing additional header name/value pairs

Return Value

bool

true on success or false on failure.

array getHeaders()

(PECL pecl_http >= 0.10.0)
Get headers

Return Value

array

an associative array containing all currently set headers.

bool setHeaders(array|null $headers = null)

(PECL pecl_http >= 0.12.0)
Set headers

Parameters

array|null $headers

[optional]

an associative array as parameter containing header name/value pairs; if empty or omitted, all previously set headers will be unset

Return Value

bool

true on success or false on failure.

bool addCookies(array $cookies)

(PECL pecl_http >= 0.10.0)
Add cookies

Parameters

array $cookies

an associative array containing any cookie name/value pairs to add

Return Value

bool

true on success or false on failure.

array getCookies()

(PECL pecl_http >= 0.10.0)
Get cookies

Return Value

array

an associative array containing any previously set cookies.

bool setCookies(array|null $cookies = null)

(PECL pecl_http >= 0.12.0)
Set cookies

Parameters

array|null $cookies

[optional]

an associative array as parameter containing cookie name/value pairs; if empty or omitted, all previously set cookies will be unset

Return Value

bool

true on success or false on failure.

bool enableCookies()

(PECL pecl_http >= 1.0.0)
Enable cookies

Return Value

bool

true on success or false on failure.

bool resetCookies(bool $session_only = null)

(PECL pecl_http >= 1.0.0)
Reset cookies

Parameters

bool $session_only

[optional]

whether only session cookies should be reset (needs libcurl >= v7.15.4, else libcurl >= v7.14.1)

Return Value

bool

true on success or false on failure.

flushCookies()

No description

bool setMethod(int $request_method)

(PECL pecl_http >= 0.10.0)
Set method

Parameters

int $request_method

the request method to use

Return Value

bool

true on success or false on failure.

int getMethod()

(PECL pecl_http >= 0.10.0)
Get method

Return Value

int

the currently set request method.

bool setUrl(string $url)

(PECL pecl_http >= 0.10.0)
Set URL

Parameters

string $url

the request url

Return Value

bool

true on success or false on failure.

string getUrl()

(PECL pecl_http >= 0.10.0)
Get url

Return Value

string

the currently set request url as string.

bool setContentType(string $content_type)

(PECL pecl_http >= 0.10.0)
Set content type

Parameters

string $content_type

the content type of the request (primary/secondary)

Return Value

bool

TRUE on success, or FALSE if the content type does not seem to contain a primary and a secondary part.

string getContentType()

(PECL pecl_http >= 0.10.0)
Get content type

Return Value

string

the previously set content type as string.

bool setQueryData(mixed $query_data)

(PECL pecl_http >= 0.10.0)
Set query data

Parameters

mixed $query_data

a string or associative array parameter containing the pre-encoded query string or to be encoded query fields; if empty, the query data will be unset

Return Value

bool

true on success or false on failure.

string getQueryData()

(PECL pecl_http >= 0.10.0)
Get query data

Return Value

string

a string containing the urlencoded query.

bool addQueryData(array $query_params)

(PECL pecl_http >= 0.10.0)
Add query data

Parameters

array $query_params

an associative array as parameter containing the query fields to add

Return Value

bool

true on success or false on failure.

bool setPostFields(array $post_data)

(PECL pecl_http >= 0.10.0)
Set post fields

Parameters

array $post_data

an associative array containing the post fields; if empty, the post data will be unset

Return Value

bool

true on success or false on failure.

array getPostFields()

(PECL pecl_http >= 0.10.0)
Get post fields

Return Value

array

the currently set post fields as associative array.

bool addPostFields(array $post_data)

(PECL pecl_http >= 0.10.0)
Add post fields

Parameters

array $post_data

an associative array as parameter containing the post fields

Return Value

bool

true on success or false on failure.

setBody($request_body_data)

No description

Parameters

$request_body_data [optional]

getBody()

No description

addBody($request_body_data)

No description

Parameters

$request_body_data

bool setRawPostData(string $raw_post_data = null)

(PECL pecl_http 0.14.0-1.4.1)
Set raw post data

Parameters

string $raw_post_data

[optional]

raw post data

Return Value

bool

true on success or false on failure.

string getRawPostData()

(PECL pecl_http 0.14.0-1.4.1)
Get raw post data

Return Value

string

a string containing the currently set raw post data.

bool addRawPostData(string $raw_post_data)

(PECL pecl_http 0.14.0-1.4.1)
Add raw post data

Parameters

string $raw_post_data

the raw post data to concatenate

Return Value

bool

true on success or false on failure.

bool setPostFiles(array $post_files)

(PECL pecl_http >= 0.10.0)
Set post files

Parameters

array $post_files

an array containing the files to post; if empty, the post files will be unset

Return Value

bool

true on success or false on failure.

bool addPostFile(string $name, string $file, string $content_type = null)

(PECL pecl_http >= 0.10.0)
Add post file

Parameters

string $name

the form element name

string $file

the path to the file

string $content_type

[optional]

the content type of the file

Return Value

bool

TRUE on success, or FALSE if the content type seems not to contain a primary and a secondary content type part.

array getPostFiles()

(PECL pecl_http >= 0.10.0)
Get post files

Return Value

array

an array containing currently set post files.

bool setPutFile(string $file = null)

(PECL pecl_http >= 0.10.0)
Set put file

Parameters

string $file

[optional]

the path to the file to send; if empty or omitted the put file will be unset

Return Value

bool

true on success or false on failure.

string getPutFile()

(PECL pecl_http >= 0.10.0)
Get put file

Return Value

string

a string containing the path to the currently set put file.

bool setPutData(string $put_data = null)

(PECL pecl_http >= 0.25.0)
Set put data

Parameters

string $put_data

[optional]

the data to upload

Return Value

bool

true on success or false on failure.

string getPutData()

(PECL pecl_http >= 0.25.0)
Get put data

Return Value

string

a string containing the currently set PUT data.

bool addPutData(string $put_data)

(PECL pecl_http >= 0.25.0)
Add put data

Parameters

string $put_data

the data to concatenate

Return Value

bool

true on success or false on failure.

HttpMessage send()

(PECL pecl_http >= 0.10.0)
Send request

Return Value

HttpMessage

the received response as HttpMessage object.

array getResponseData()

(PECL pecl_http >= 0.10.0)
Get response data

Return Value

array

an associative array with the key "headers" containing an associative array holding all response headers, as well as the key "body" containing a string with the response body.

mixed getResponseHeader(string $name = null)

(PECL pecl_http >= 0.10.0)
Get response header(s)

Parameters

string $name

[optional]

header to read; if empty, all response headers will be returned

Return Value

mixed

either a string with the value of the header matching name if requested, FALSE on failure, or an associative array containing all response headers.

stdClass[] getResponseCookies(int $flags = null, array|null $allowed_extras = null)

(PECL pecl_http >= 0.23.0)
Get response cookie(s)

Parameters

int $flags

[optional]

http_parse_cookie flags

array|null $allowed_extras

[optional]

allowed keys treated as extra information instead of cookie names

Return Value

stdClass[]

an array of stdClass objects like http_parse_cookie would return.

int getResponseCode()

(PECL pecl_http >= 0.10.0)
Get response code

Return Value

int

an int representing the response code.

string getResponseStatus()

(PECL pecl_http >= 0.23.0)
Get response status

Return Value

string

a string containing the response status text.

string getResponseBody()

(PECL pecl_http >= 0.10.0)
Get response body

Return Value

string

a string containing the response body.

mixed getResponseInfo(string $name = null)

(PECL pecl_http >= 0.10.0)
Get response info

Parameters

string $name

[optional]

the info to read; if empty or omitted, an associative array containing all available info will be returned

Return Value

mixed

either a scalar containing the value of the info matching name if requested, FALSE on failure, or an associative array containing all available info.

HttpMessage getResponseMessage()

(PECL pecl_http >= 0.10.0)
Get response message

Return Value

HttpMessage

an HttpMessage object of the response.

string getRawResponseMessage()

(PECL pecl_http >= 0.21.0)
Get raw response message

Return Value

string

the complete web server response, including the headers in a form of a string.

HttpMessage getRequestMessage()

(PECL pecl_http >= 0.11.0)
Get request message

Return Value

HttpMessage

an HttpMessage object representing the sent request.

string getRawRequestMessage()

(PECL pecl_http >= 0.21.0)
Get raw request message

Return Value

string

an HttpMessage in a form of a string.

HttpMessage getHistory()

(PECL pecl_http >= 0.15.0)
Get history

Return Value

HttpMessage

an HttpMessage object representing the complete request/response history.

void clearHistory()

(PECL pecl_http >= 0.15.0)
Clear history

Return Value

void

static factory($url, $method, $options, $class_name)

No description

Parameters

$url [optional]
$method [optional]
$options [optional]
$class_name [optional]

static get($url, $options, $info)

No description

Parameters

$url
$options [optional]
$info [optional]

static head($url, $options, $info)

No description

Parameters

$url
$options [optional]
$info [optional]

static postData($url, $data, $options, $info)

No description

Parameters

$url
$data
$options [optional]
$info [optional]

static postFields($url, $data, $options, $info)

No description

Parameters

$url
$data
$options [optional]
$info [optional]

static putData($url, $data, $options, $info)

No description

Parameters

$url
$data
$options [optional]
$info [optional]

static putFile($url, $file, $options, $info)

No description

Parameters

$url
$file
$options [optional]
$info [optional]

static putStream($url, $stream, $options, $info)

No description

Parameters

$url
$stream
$options [optional]
$info [optional]

static methodRegister($method_name)

No description

Parameters

$method_name

static methodUnregister($method)

No description

Parameters

$method

static methodName($method_id)

No description

Parameters

$method_id

static methodExists($method)

No description

Parameters

$method

static encodeBody($fields, $files)

No description

Parameters

$fields
$files