Options usable with the HttpRequest class and request functions

Options related to time outs
timeout (integer)
seconds the whole request may take to complete
connecttimeout (integer)
seconds the connect, including name resolving, may take
dns_cache_timeout (integer)
seconds after an dns cache entry times out
Options related to urls
url (string)
the request url
port (integer)
use another port as specified in the url
redirect (integer)
whether and how many redirects to follow; defaults to 0
unrestrictedauth (bool)
whether to continue sending credentials on redirects to a different host
referer (string)
the referring url to send
Options related to cookies
encodecookies (bool)
whether custom cookies should be urlencode()d prior sending
cookies (array)
list of cookies as associative array like array("cookie" => "value")
cookiestore (string)
path to a file where cookies are/will be stored
cookiesession (bool)
don't load session cookies from cookiestore if TRUE
Options related to headers
useragent (string)
the user agent to send; defaults to PECL::HTTP/x.y.z (PHP/x.y.z); omitted if explicitly set to an empty string
lastmodified (int)
timestamp for If-(Un)Modified-Since header
etag (string)
quoted etag for If-(None-)Match header
headers (array)
list of custom headers as associative array like array("header" => "value")
Options related to authentication
httpauth (string)
http credentials in "user:pass" format
httpauthtype (int)
HTTP authentication type constant
(array)
Options related to proxies
proxyhost (string)
proxy host in "host[:port]" format
proxyport (int)
use another proxy port as specified in proxyhost
proxytype (int)
HTTP proxy type constant
proxyauth (string)
proxy credentials in "user:pass" format
proxyauthtype (int)
HTTP authentication type constant
Options related to the transfer
compress (bool)
whether to request and accept a gzip/deflate content encoded response
resume (int)
start the download at the specified byte offset if server support is given (indicated by a 206 response code)
range (array)
array of arrays, each containing two integers, specifying the ranges to download if server support is given (indicated by a 206 response code); only recognized if the resume option is empty
Options imposing limits
maxfilesize (integer)
maximum file size that should be downloaded; has no effect, if the size of the requested entity is unknown (eg. dynamic pages with chunked transfer encoding etc.)
low_speed_limit (int)
the lowest transfer speed a successful request may have
low_speed_time (int)
the time in which low_speed_limit must be transferred for a successful request
max_send_speed (int)
maximum send speed in bytes per second
max_recv_speed (int)
maximum receive speed in bytes per second
Callback options
onprogress (callable)
progress callback
Network options
interface (string)
outgoing network interface (ifname, ip or hostname)
portrange (array)
2 integers specifying outgoing portrange to try
SSL options
ssl (array)

Note: SSL options are set through an array with the single "ssl" request option name.

cert (string)
path to certificate
certtype (string)
type of certificate
certpasswd (string)
password for certificate
key (string)
path to key
keytype (string)
type of key
keypasswd (string)
password for key
engine (string)
ssl engine to use
version (int)
ssl version to use
verifypeer (bool)
whether to verify the peer
verifyhost (bool)
whether to verify the host
cipher_list (string)
list of allowed ciphers
cainfo (string)
capath (string)
random_file (string)
egdsocket (string)

Коментарии

If anyone doesn't understand the purpose of these values and is scratching their head, they're all array indexes, and are used as the $option parameter to the various HTTP functions documented in this section. For example:

<?php
    $body 
http_get('http://example.com/private_area/', array(httpauth => 'username:password'));
    print 
$body;
?>

This only had me "...huh?!" for a little while, but might have others confused for longer as the fact that these are what they are isn't clearly printed anywhere... to find out that these did what they say they do was a guessing game for me even.

-dav7
2008-03-25 19:52:14
http://php5.kiev.ua/manual/ru/http.request.options.html
If someone looking how to use in OOP's context:

$options = array(
                        'useragent'      => "Firefox (+http://www.firefox.org)", // who am i 
                        'connecttimeout' => 120, // timeout on connect 
                        'timeout'          => 120, // timeout on response 
                        'redirect'          => 10, // stop after 10 redirects
                        'referer'           => "http://www.google.com"
                );

$request = new HttpRequest('http://example.com');
$request->setOptions($options);
$request->send();
2012-03-10 20:59:42
http://php5.kiev.ua/manual/ru/http.request.options.html

    Поддержать сайт на родительском проекте КГБ