Class: HTTP_Request2
Source Location: /HTTP_Request2-0.2.0/Request2.php
Class representing a HTTP request
Author(s):
Version:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Method Detail
__construct (Constructor) [line 199]
HTTP_Request2 __construct(
[string|Net_Url2
$url = null], [string
$method = self::METHOD_GET], [array
$config = array()])
|
|
Constructor. Can set request URL, method and configuration array. Also sets a default value for User-Agent header.
Parameters:
addCookie [line 485]
Appends a cookie to "Cookie:" header
Parameters:
addPostParameter [line 613]
HTTP_Request2 addPostParameter(
string|array
$name, [mixed
$value = null])
|
|
Adds POST parameter(s) to the request.
Parameters:
addUpload [line 566]
HTTP_Request2 addUpload(
string
$fieldName, mixed
$filename, [string
$sendFilename = null], [string
$contentType = null])
|
|
Adds a file to form-based file upload Used to emulate file upload via a HTML form. The method also sets Content-Type of HTTP request to 'multipart/form-data'. If you just want to send the contents of a file as the body of HTTP request you should use setBody() method.
Parameters:
attach [line 634]
void attach(
SplObserver
$observer)
|
|
Attaches a new observer
Parameters:
detach [line 649]
void detach(
SplObserver
$observer)
|
|
Detaches an existing observer
Parameters:
detectMimeType [line 818]
string detectMimeType(
string
$filename)
|
|
Tries to detect MIME type of a file The method will try to use fileinfo extension if it is available, deprecated mime_content_type() function in the other case. If neither works, default 'application/octet-stream' MIME type is returned
Parameters:
getAuth [line 405]
Returns the authentication data The array has the keys 'user', 'password' and 'scheme', where 'scheme' is one of the HTTP_Request2::AUTH_* constants.
getBody [line 528]
getConfig [line 348]
mixed getConfig(
[string
$name = null])
|
|
Returns the value(s) of the configuration parameter(s)
Parameters:
getConfigValue [line 369]
mixed getConfigValue(
string
$name)
|
|
Returns the value of the configuration parameter (DEPRECATED)
Parameters:
getHeaders [line 472]
Returns the request headers The array is of the form ('header name' => 'header value'), header names are lowercased
getLastEvent [line 714]
Returns the last event Observers should use this method to access the last change in request. The following event names are possible: - 'connect' - after connection to remote server,
data is the destination (string)
- 'disconnect' - after disconnection from server
- 'sentHeaders' - after sending the request headers,
data is the headers sent (string)
- 'sentBodyPart' - after sending a part of the request body,
data is the length of that part (int)
- 'receivedHeaders' - after receiving the response headers,
data is HTTP_Request2_Response object
- 'receivedBodyPart' - after receiving a part of the response
body, data is that part (string)
- 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still
encoded by Content-Encoding
- 'receivedBody' - after receiving the complete response
body, data is HTTP_Request2_Response object
Different adapters may not send all the event types. Mock adapter does not send any events to the observers.
getMethod [line 280]
Returns the request method
getUrl [line 252]
notify [line 662]
send [line 765]
Sends the request and returns the response
setAdapter [line 735]
Sets the adapter used to actually perform the request You can pass either an instance of a class implementing HTTP_Request2_Adapter or a class name. The method will only try to include a file if the class name starts with HTTP_Request2_Adapter_, it will also try to prepend this prefix to the class name if it doesn't contain any underscores, so that
will work.
Parameters:
setAuth [line 382]
HTTP_Request2 setAuth(
string
$user, [string
$password = ''], [string
$scheme = self::AUTH_BASIC])
|
|
Sets the autentification data
Parameters:
setBody [line 506]
Sets the request body
Parameters:
setConfig [line 321]
HTTP_Request2 setConfig(
string|array
$nameOrConfig, [mixed
$value = null])
|
|
Sets the configuration parameter(s) The following parameters are available: - 'adapter' - adapter to use (string)
- 'connect_timeout' - Connection timeout in seconds (integer)
- 'timeout' - Total number of seconds a request can take.
Use 0 for no limit, should be greater than
'connect_timeout' if set (integer)
- 'use_brackets' - Whether to append [] to array variable names (bool)
- 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
- 'buffer_size' - Buffer size to use for reading and writing (int)
- 'proxy_host' - Proxy server host (string)
- 'proxy_port' - Proxy server port (integer)
- 'proxy_user' - Proxy auth username (string)
- 'proxy_password' - Proxy auth password (string)
- 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
- 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
- 'ssl_verify_host' - Whether to check that Common Name in SSL
certificate matches host name (bool)
- 'ssl_cafile' - Cerificate Authority file to verify the peer
with (use with 'ssl_verify_peer') (string)
- 'ssl_capath' - Directory holding multiple Certificate
Authority files (string)
- 'ssl_local_cert' - Name of a file containing local cerificate (string)
- 'ssl_passphrase' - Passphrase with which local certificate
was encoded (string)
Parameters:
setHeader [line 434]
HTTP_Request2 setHeader(
string|array
$name, [string|null
$value = null])
|
|
Sets request header(s) The first parameter may be either a full header string 'header: value' or header name. In the former case $value parameter is ignored, in the latter the header's value will either be set to $value or the header will be removed if $value is null. The first parameter can also be an array of headers, in that case method will be called recursively. Note that headers are treated case insensitively as per RFC 2616. $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar'
$req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz'
$req->setHeader(array ('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux'
$req->setHeader('FOO'); // removes 'Foo' header from request
Parameters:
setLastEvent [line 678]
void setLastEvent(
string
$name, [mixed
$data = null])
|
|
Sets the last event Adapters should use this method to set the current state of the request and notify the observers.
Parameters:
setMethod [line 264]
Sets the request method
Parameters:
setUrl [line 224]
Sets the URL for this request If the URL has userinfo part (username & password) these will be removed and converted to auth data. If the URL does not have a path component, that will be set to '/'.
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:28:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|