ILIAS
release_5-0 Revision 5.0.0-1144-gc4397b1f870
|
Public Member Functions | |
HTTP_Request ($url='', $params=array()) | |
#- More... | |
_generateHostHeader () | |
Generates a Host header for HTTP/1.1 requests. More... | |
reset ($url, $params=array()) | |
Resets the object to its initial state (DEPRECATED). More... | |
setURL ($url) | |
Sets the URL to be requested. More... | |
getUrl () | |
Returns the current request URL. More... | |
setProxy ($host, $port=8080, $user=null, $pass=null) | |
Sets a proxy to be used. More... | |
setBasicAuth ($user, $pass) | |
Sets basic authentication parameters. More... | |
setMethod ($method) | |
Sets the method to be used, GET, POST etc. More... | |
setHttpVer ($http) | |
Sets the HTTP version to use, 1.0 or 1.1. More... | |
addHeader ($name, $value) | |
Adds a request header. More... | |
removeHeader ($name) | |
Removes a request header. More... | |
addQueryString ($name, $value, $preencoded=false) | |
Adds a querystring parameter. More... | |
addRawQueryString ($querystring, $preencoded=true) | |
Sets the querystring to literally what you supply. More... | |
addPostData ($name, $value, $preencoded=false) | |
Adds postdata items. More... | |
_arrayMapRecursive ($callback, $value) | |
Recursively applies the callback function to the value. More... | |
addFile ($inputName, $fileName, $contentType='application/octet-stream') | |
Adds a file to form-based file upload. More... | |
addRawPostData ($postdata, $preencoded=true) | |
Adds raw postdata (DEPRECATED) More... | |
setBody ($body) | |
Sets the request body (for POST, PUT and similar requests) More... | |
clearPostData () | |
Clears any postdata that has been added (DEPRECATED). More... | |
addCookie ($name, $value) | |
Appends a cookie to "Cookie:" header. More... | |
clearCookies () | |
Clears any cookies that have been added (DEPRECATED). More... | |
sendRequest ($saveBody=true) | |
Sends the request. More... | |
disconnect () | |
Disconnect the socket, if connected. More... | |
getResponseCode () | |
Returns the response code. More... | |
getResponseReason () | |
Returns the response reason phrase. More... | |
getResponseHeader ($headername=null) | |
Returns either the named header or all if no name given. More... | |
getResponseBody () | |
Returns the body of the response. More... | |
getResponseCookies () | |
Returns cookies set in response. More... | |
_buildRequest () | |
Builds the request string. More... | |
_flattenArray ($name, $values) | |
Helper function to change the (probably multidimensional) associative array into the simple one. More... | |
attach (&$listener) | |
Adds a Listener to the list of listeners that are notified of the object's events. More... | |
detach (&$listener) | |
Removes a Listener from the list of listeners. More... | |
_notify ($event, $data=null) | |
Notifies all registered listeners of an event. More... | |
Data Fields | |
$_url | |
$_method | |
$_http | |
$_requestHeaders | |
$_user | |
$_pass | |
$_sock | |
$_proxy_host | |
$_proxy_port | |
$_proxy_user | |
$_proxy_pass | |
$_postData | |
$_body | |
$_bodyDisallowed = array('TRACE') | |
$_bodyRequired = array('POST', 'PUT') | |
$_postFiles = array() | |
$_timeout | |
$_response | |
$_allowRedirects | |
$_maxRedirects | |
$_redirects | |
$_useBrackets = true | |
$_listeners = array() | |
$_saveBody = true | |
$_readTimeout = null | |
$_socketOptions = null | |
Definition at line 121 of file Request.php.
HTTP_Request::_arrayMapRecursive | ( | $callback, | |
$value | |||
) |
Recursively applies the callback function to the value.
mixed | Callback function |
mixed | Value to process private |
Definition at line 571 of file Request.php.
Referenced by addPostData().
HTTP_Request::_buildRequest | ( | ) |
Builds the request string.
private
Definition at line 912 of file Request.php.
References $_body, $filename, $path, $separator, _flattenArray(), addHeader(), HTTP_REQUEST_METHOD_POST, if, and removeHeader().
Referenced by sendRequest().
HTTP_Request::_flattenArray | ( | $name, | |
$values | |||
) |
Helper function to change the (probably multidimensional) associative array into the simple one.
string | name for item |
mixed | item's values |
Definition at line 1036 of file Request.php.
References $ret.
Referenced by _buildRequest().
HTTP_Request::_generateHostHeader | ( | ) |
Generates a Host header for HTTP/1.1 requests.
private
Definition at line 371 of file Request.php.
Referenced by sendRequest(), and setURL().
HTTP_Request::_notify | ( | $event, | |
$data = null |
|||
) |
Notifies all registered listeners of an event.
string | Event name |
mixed | Additional data private |
Definition at line 1112 of file Request.php.
References $data.
Referenced by disconnect(), HTTP_Response\process(), and sendRequest().
HTTP_Request::addCookie | ( | $name, | |
$value | |||
) |
Appends a cookie to "Cookie:" header.
string | $name | cookie name |
string | $value | cookie value public |
Definition at line 663 of file Request.php.
References addHeader().
HTTP_Request::addFile | ( | $inputName, | |
$fileName, | |||
$contentType = 'application/octet-stream' |
|||
) |
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.
public
string | name of file-upload field |
mixed | file name(s) |
mixed | content-type(s) of file(s) being uploaded |
PEAR_Error |
Definition at line 600 of file Request.php.
References addHeader(), HTTP_REQUEST_ERROR_FILE, and PEAR\raiseError().
HTTP_Request::addHeader | ( | $name, | |
$value | |||
) |
Adds a request header.
string | Header name |
string | Header value public |
Definition at line 503 of file Request.php.
Referenced by _buildRequest(), addCookie(), addFile(), HTTP_Request(), sendRequest(), setBasicAuth(), setProxy(), and setURL().
HTTP_Request::addPostData | ( | $name, | |
$value, | |||
$preencoded = false |
|||
) |
Adds postdata items.
string | Post data name |
string | Post data value |
bool | Whether data is already urlencoded or not, default = not public |
Definition at line 554 of file Request.php.
References _arrayMapRecursive().
HTTP_Request::addQueryString | ( | $name, | |
$value, | |||
$preencoded = false |
|||
) |
Adds a querystring parameter.
string | Querystring parameter name |
string | Querystring parameter value |
bool | Whether the value is already urlencoded or not, default = not public |
Definition at line 529 of file Request.php.
HTTP_Request::addRawPostData | ( | $postdata, | |
$preencoded = true |
|||
) |
Adds raw postdata (DEPRECATED)
string | The data |
bool | Whether data is preencoded or not, default = already encoded public |
Definition at line 627 of file Request.php.
HTTP_Request::addRawQueryString | ( | $querystring, | |
$preencoded = true |
|||
) |
Sets the querystring to literally what you supply.
string | The querystring data. Should be of the format foo=bar&x=y etc |
bool | Whether data is already urlencoded or not, default = already encoded public |
Definition at line 541 of file Request.php.
HTTP_Request::attach | ( | & | $listener | ) |
Adds a Listener to the list of listeners that are notified of the object's events.
Events sent by HTTP_Request object
Events sent by HTTP_Response object
HTTP_Request_Listener | listener to attach |
Definition at line 1076 of file Request.php.
HTTP_Request::clearCookies | ( | ) |
Clears any cookies that have been added (DEPRECATED).
Useful for multiple request scenarios
public
Definition at line 677 of file Request.php.
References removeHeader().
HTTP_Request::clearPostData | ( | ) |
Clears any postdata that has been added (DEPRECATED).
Useful for multiple request scenarios.
public
Definition at line 651 of file Request.php.
HTTP_Request::detach | ( | & | $listener | ) |
Removes a Listener from the list of listeners.
HTTP_Request_Listener | listener to detach |
Definition at line 1093 of file Request.php.
HTTP_Request::disconnect | ( | ) |
Disconnect the socket, if connected.
Only useful if using Keep-Alive.
public
Definition at line 836 of file Request.php.
References _notify().
Referenced by sendRequest().
HTTP_Request::getResponseBody | ( | ) |
Returns the body of the response.
public
Definition at line 890 of file Request.php.
HTTP_Request::getResponseCode | ( | ) |
Returns the response code.
public
Definition at line 850 of file Request.php.
Referenced by sendRequest().
HTTP_Request::getResponseCookies | ( | ) |
Returns cookies set in response.
public
Definition at line 901 of file Request.php.
HTTP_Request::getResponseHeader | ( | $headername = null | ) |
Returns either the named header or all if no name given.
public
string | The header name to return, do not set to get all headers |
Definition at line 874 of file Request.php.
HTTP_Request::getResponseReason | ( | ) |
Returns the response reason phrase.
public
Definition at line 861 of file Request.php.
HTTP_Request::getUrl | ( | ) |
Returns the current request URL.
Definition at line 434 of file Request.php.
HTTP_Request::HTTP_Request | ( | $url = '' , |
|
$params = array() |
|||
) |
#-
Constructor
Sets up the object
string | The url to fetch/access |
array | Associative array of parameters which can have the following keys:
|
Definition at line 312 of file Request.php.
References addHeader(), HTTP_REQUEST_HTTP_VER_1_1, HTTP_REQUEST_METHOD_GET, and setURL().
Referenced by reset().
HTTP_Request::removeHeader | ( | $name | ) |
Removes a request header.
string | Header name to remove public |
Definition at line 514 of file Request.php.
Referenced by _buildRequest(), clearCookies(), and sendRequest().
HTTP_Request::reset | ( | $url, | |
$params = array() |
|||
) |
Resets the object to its initial state (DEPRECATED).
Takes the same parameters as the constructor.
string | $url | The url to be requested |
array | $params | Associative array of parameters (see constructor for details) public |
Definition at line 399 of file Request.php.
References HTTP_Request().
HTTP_Request::sendRequest | ( | $saveBody = true | ) |
Sends the request.
public
bool | Whether to store response body in Response object property, set this to false if downloading a LARGE file and using a Listener |
Definition at line 690 of file Request.php.
References $_sock, $redirect, _buildRequest(), _generateHostHeader(), _notify(), addHeader(), disconnect(), getResponseCode(), PEAR\getStaticProperty(), HTTP_REQUEST_ERROR_PROXY, HTTP_REQUEST_ERROR_REDIRECTS, HTTP_REQUEST_ERROR_URL, HTTP_REQUEST_HTTP_VER_1_1, HTTP_REQUEST_METHOD_HEAD, PEAR\isError(), PEAR\raiseError(), removeHeader(), and Net_URL\resolvePath().
HTTP_Request::setBasicAuth | ( | $user, | |
$pass | |||
) |
Sets basic authentication parameters.
string | Username |
string | Password |
Definition at line 466 of file Request.php.
References $pass, and addHeader().
Referenced by setURL().
HTTP_Request::setBody | ( | $body | ) |
Sets the request body (for POST, PUT and similar requests)
string | Request body public |
Definition at line 638 of file Request.php.
HTTP_Request::setHttpVer | ( | $http | ) |
Sets the HTTP version to use, 1.0 or 1.1.
string | Version to use. Use the defined constants for this public |
Definition at line 491 of file Request.php.
HTTP_Request::setMethod | ( | $method | ) |
Sets the method to be used, GET, POST etc.
string | Method to use. Use the defined constants for this public |
Definition at line 480 of file Request.php.
HTTP_Request::setProxy | ( | $host, | |
$port = 8080 , |
|||
$user = null , |
|||
$pass = null |
|||
) |
Sets a proxy to be used.
string | Proxy host |
int | Proxy port |
string | Proxy username |
string | Proxy password public |
Definition at line 448 of file Request.php.
References $pass, and addHeader().
HTTP_Request::setURL | ( | $url | ) |
Sets the URL to be requested.
string | The url to be requested public |
Definition at line 410 of file Request.php.
References _generateHostHeader(), addHeader(), HTTP_REQUEST_HTTP_VER_1_1, and setBasicAuth().
Referenced by HTTP_Request().
HTTP_Request::$_allowRedirects |
Definition at line 242 of file Request.php.
HTTP_Request::$_body |
Definition at line 202 of file Request.php.
Referenced by _buildRequest().
HTTP_Request::$_bodyDisallowed = array('TRACE') |
Definition at line 208 of file Request.php.
HTTP_Request::$_bodyRequired = array('POST', 'PUT') |
Definition at line 218 of file Request.php.
HTTP_Request::$_http |
Definition at line 142 of file Request.php.
HTTP_Request::$_listeners = array() |
Definition at line 266 of file Request.php.
HTTP_Request::$_maxRedirects |
Definition at line 248 of file Request.php.
HTTP_Request::$_method |
Definition at line 136 of file Request.php.
HTTP_Request::$_pass |
Definition at line 160 of file Request.php.
HTTP_Request::$_postData |
Definition at line 196 of file Request.php.
HTTP_Request::$_postFiles = array() |
Definition at line 224 of file Request.php.
HTTP_Request::$_proxy_host |
Definition at line 172 of file Request.php.
HTTP_Request::$_proxy_pass |
Definition at line 190 of file Request.php.
HTTP_Request::$_proxy_port |
Definition at line 178 of file Request.php.
HTTP_Request::$_proxy_user |
Definition at line 184 of file Request.php.
HTTP_Request::$_readTimeout = null |
Definition at line 278 of file Request.php.
HTTP_Request::$_redirects |
Definition at line 254 of file Request.php.
HTTP_Request::$_requestHeaders |
Definition at line 148 of file Request.php.
HTTP_Request::$_response |
Definition at line 236 of file Request.php.
HTTP_Request::$_saveBody = true |
Definition at line 272 of file Request.php.
HTTP_Request::$_sock |
Definition at line 166 of file Request.php.
Referenced by sendRequest().
HTTP_Request::$_socketOptions = null |
Definition at line 284 of file Request.php.
HTTP_Request::$_timeout |
Definition at line 230 of file Request.php.
HTTP_Request::$_url |
Definition at line 130 of file Request.php.
HTTP_Request::$_useBrackets = true |
Definition at line 260 of file Request.php.
HTTP_Request::$_user |
Definition at line 154 of file Request.php.