|
Moodle
2.2.1
http://www.collinsharper.com
|

Public Member Functions | |
| __construct ($uri=null, $config=null) | |
| setUri ($uri) | |
| getUri ($as_string=false) | |
| setConfig ($config=array()) | |
| setMethod ($method=self::GET) | |
| setHeaders ($name, $value=null) | |
| getHeader ($key) | |
| setParameterGet ($name, $value=null) | |
| setParameterPost ($name, $value=null) | |
| getRedirectionsCount () | |
| setAuth ($user, $password= '', $type=self::AUTH_BASIC) | |
| setCookieJar ($cookiejar=true) | |
| getCookieJar () | |
| setCookie ($cookie, $value=null) | |
| setFileUpload ($filename, $formname, $data=null, $ctype=null) | |
| setEncType ($enctype=self::ENC_URLENCODED) | |
| setRawData ($data, $enctype=null) | |
| resetParameters ($clearAll=false) | |
| getLastRequest () | |
| getLastResponse () | |
| setAdapter ($adapter) | |
| getAdapter () | |
| setStream ($streamfile=true) | |
| getStream () | |
| request ($method=null) | |
Static Public Member Functions | |
| static | encodeFormData ($boundary, $name, $value, $filename=null, $headers=array()) |
| static | encodeAuthHeader ($user, $password, $type=self::AUTH_BASIC) |
Data Fields | |
| const | GET = 'GET' |
| const | POST = 'POST' |
| const | PUT = 'PUT' |
| const | HEAD = 'HEAD' |
| const | DELETE = 'DELETE' |
| const | TRACE = 'TRACE' |
| const | OPTIONS = 'OPTIONS' |
| const | CONNECT = 'CONNECT' |
| const | MERGE = 'MERGE' |
| const | AUTH_BASIC = 'basic' |
| const | HTTP_1 = '1.1' |
| const | HTTP_0 = '1.0' |
| const | CONTENT_TYPE = 'Content-Type' |
| const | CONTENT_LENGTH = 'Content-Length' |
| const | ENC_URLENCODED = 'application/x-www-form-urlencoded' |
| const | ENC_FORMDATA = 'multipart/form-data' |
Protected Member Functions | |
| _setParameter ($type, $name, $value) | |
| _openTempStream () | |
| _prepareHeaders () | |
| _prepareBody () | |
| _getParametersRecursive ($parray, $urlencode=false) | |
| _detectFileMimeType ($file) | |
Static Protected Member Functions | |
| static | _flattenParametersArray ($parray, $prefix=null) |
Protected Attributes | |
| $config | |
| $adapter = null | |
| $uri = null | |
| $headers = array() | |
| $method = self::GET | |
| $paramsGet = array() | |
| $paramsPost = array() | |
| $enctype = null | |
| $raw_post_data = null | |
| $auth | |
| $files = array() | |
| $cookiejar = null | |
| $last_request = null | |
| $last_response = null | |
| $redirectCounter = 0 | |
Static Protected Attributes | |
| static | $_fileInfoDb = null |
Definition at line 66 of file Client.php.
| __construct | ( | $ | uri = null, |
| $ | config = null |
||
| ) |
Contructor method. Will create a new HTTP client. Accepts the target URL and optionally configuration array.
| Zend_Uri_Http | string | $uri | |
| array | $config | Configuration key-value pairs. |
Definition at line 249 of file Client.php.

| _detectFileMimeType | ( | $ | file | ) | [protected] |
Attempt to detect the MIME type of a file using available extensions
This method will try to detect the MIME type of a file. If the fileinfo extension is available, it will be used. If not, the mime_magic extension which is deprected but is still available in many PHP setups will be tried.
If neither extension is available, the default application/octet-stream MIME type will be returned
| string | $file | File path |
Definition at line 1317 of file Client.php.

| static _flattenParametersArray | ( | $ | parray, |
| $ | prefix = null |
||
| ) | [static, protected] |
Convert an array of parameters into a flat array of (key, value) pairs
Will flatten a potentially multi-dimentional array of parameters (such as POST parameters) into a flat array of (key, value) paris. In case of multi-dimentional arrays, square brackets ([]) will be added to the key to indicate an array.
| array | $parray | |
| string | $prefix |
Definition at line 1428 of file Client.php.

| _getParametersRecursive | ( | $ | parray, |
| $ | urlencode = false |
||
| ) | [protected] |
Helper method that gets a possibly multi-level parameters array (get or post) and flattens it.
The method returns an array of (key, value) pairs (because keys are not necessarily unique. If one of the parameters in as array, it will also add a [] suffix to the key.
This method is deprecated since Zend Framework 1.9 in favour of self::_flattenParametersArray() and will be dropped in 2.0
| array | $parray | The parameters array |
| bool | $urlencode | Whether to urlencode the name and value |
Definition at line 1267 of file Client.php.
| _openTempStream | ( | ) | [protected] |
Create temporary stream
Definition at line 904 of file Client.php.

| _prepareBody | ( | ) | [protected] |
Prepare the request body (for POST and PUT requests)
| Zend_Http_Client_Exception |
Reimplemented in Zend_Gdata_HttpClient.
Definition at line 1160 of file Client.php.


| _prepareHeaders | ( | ) | [protected] |
Prepare the request headers
Definition at line 1079 of file Client.php.


| _setParameter | ( | $ | type, |
| $ | name, | ||
| $ | value | ||
| ) | [protected] |
Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
| string | $type | GET or POST |
| string | $name | |
| string | $value |
Definition at line 493 of file Client.php.

| static encodeAuthHeader | ( | $ | user, |
| $ | password, | ||
| $ | type = self::AUTH_BASIC |
||
| ) | [static] |
Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
| string | $user | |
| string | $password | |
| string | $type |
| Zend_Http_Client_Exception |
Definition at line 1383 of file Client.php.

| static encodeFormData | ( | $ | boundary, |
| $ | name, | ||
| $ | value, | ||
| $ | filename = null, |
||
| $ | headers = array() |
||
| ) | [static] |
| getAdapter | ( | ) |
Load the connection adapter
Reimplemented in Zend_Gdata_HttpClient.
Definition at line 873 of file Client.php.
| getCookieJar | ( | ) |
Return the current cookie jar or null if none.
Definition at line 612 of file Client.php.
| getHeader | ( | $ | key | ) |
Get the value of a specific header
Note that if the header has more than one value, an array will be returned.
| string | $key |
Definition at line 437 of file Client.php.
| getLastRequest | ( | ) |
| getLastResponse | ( | ) |
Get the last HTTP response received by this client
If $config['storeresponse'] is set to false, or no response was stored yet, will return null
Definition at line 824 of file Client.php.
Get the number of redirections done on the last request
Definition at line 518 of file Client.php.
| getStream | ( | ) |
Get status of streaming for received data
Definition at line 894 of file Client.php.
| getUri | ( | $ | as_string = false | ) |
Get the URI for the next request
| boolean | $as_string | If true, will return the URI as a string |
Definition at line 299 of file Client.php.

| request | ( | $ | method = null | ) |
Send the HTTP request and return an HTTP response object
| string | $method |
| Zend_Http_Client_Exception |
Definition at line 931 of file Client.php.

| resetParameters | ( | $ | clearAll = false | ) |
Clear all GET and POST parameters
Should be used to reset the request parameters if the client is used for several concurrent requests.
clearAll parameter controls if we clean just parameters or also headers and last_*
| bool | $clearAll | Should all data be cleared? |
Reimplemented in Zend_Gdata_HttpClient.
Definition at line 781 of file Client.php.

| setAdapter | ( | $ | adapter | ) |
Load the connection adapter
While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability
| Zend_Http_Client_Adapter_Interface | string | $adapter |
| Zend_Http_Client_Exception |
Reimplemented in Zend_Gdata_HttpClient.
Definition at line 839 of file Client.php.


| setAuth | ( | $ | user, |
| $ | password = '', |
||
| $ | type = self::AUTH_BASIC |
||
| ) |
Set HTTP authentication parameters
$type should be one of the supported types - see the self::AUTH_* constants.
To enable authentication: $this->setAuth('shahar', 'secret', Zend_Http_Client::AUTH_BASIC);
To disable authentication: $this->setAuth(false);
| string | false | $user | User name or false disable authentication |
| string | $password | Password |
| string | $type | Authentication type |
| Zend_Http_Client_Exception |
Definition at line 546 of file Client.php.


Set configuration parameters for this HTTP client
| Zend_Config | | array $config |
| Zend_Http_Client_Exception |
Definition at line 315 of file Client.php.

| setCookie | ( | $ | cookie, |
| $ | value = null |
||
| ) |
Add a cookie to the request. If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.
| Zend_Http_Cookie | string | $cookie | |
| string | null | $value | If "cookie" is a string, this is the cookie value. |
| Zend_Http_Client_Exception |
Definition at line 626 of file Client.php.

| setCookieJar | ( | $ | cookiejar = true | ) |
Set the HTTP client's cookie jar.
A cookie jar is an object that holds and maintains cookies across HTTP requests and responses.
| Zend_Http_CookieJar | boolean | $cookiejar | Existing cookiejar object, true to create a new one, false to disable |
| Zend_Http_Client_Exception |
Definition at line 586 of file Client.php.
| setEncType | ( | $ | enctype = self::ENC_URLENCODED | ) |
Set the encoding type for POST data
| string | $enctype |
Definition at line 734 of file Client.php.

| setFileUpload | ( | $ | filename, |
| $ | formname, | ||
| $ | data = null, |
||
| $ | ctype = null |
||
| ) |
Set a file to upload (using a POST request)
Can be used in two ways:
1. $data is null (default): $filename is treated as the name if a local file which will be read and sent. Will try to guess the content type using mime_content_type(). 2. $data is set - $filename is sent as the file name, but $data is sent as the file contents and no file is read from the file system. In this case, you need to manually set the Content-Type ($ctype) or it will default to application/octet-stream.
| string | $filename | Name of file to upload, or name to save as |
| string | $formname | Name of form element to send as |
| string | $data | Data to send (if null, $filename is read and sent) |
| string | $ctype | Content type to use (if $data is set and $ctype is null, will be application/octet-stream) |
| Zend_Http_Client_Exception |
Definition at line 701 of file Client.php.

| setHeaders | ( | $ | name, |
| $ | value = null |
||
| ) |
Set one or more request headers
This function can be used in several ways to set the client's request headers: 1. By providing two parameters: $name as the header to set (eg. 'Host') and $value as it's value (eg. 'www.example.com'). 2. By providing a single header string as the only parameter eg. 'Host: www.example.com' 3. By providing an array of headers as the first parameter eg. array('host' => 'www.example.com', 'x-foo: bar'). In This case the function will call itself recursively for each array item.
| string | array | $name | Header name, full header string ('Header: value') or an array of headers |
| mixed | $value | Header value or null |
| Zend_Http_Client_Exception |
Definition at line 385 of file Client.php.

| setMethod | ( | $ | method = self::GET | ) |
Set the next request's method
Validated the passed method and sets it. If we have files set for POST requests, and the new method is not POST, the files are silently dropped.
| string | $method |
| Zend_Http_Client_Exception |
Definition at line 349 of file Client.php.


| setParameterGet | ( | $ | name, |
| $ | value = null |
||
| ) |
Set a GET parameter for the request. Wrapper around _setParameter
| string | array | $name | |
| string | $value |
Definition at line 454 of file Client.php.

| setParameterPost | ( | $ | name, |
| $ | value = null |
||
| ) |
Set a POST parameter for the request. Wrapper around _setParameter
| string | array | $name | |
| string | $value |
Definition at line 473 of file Client.php.

| setRawData | ( | $ | data, |
| $ | enctype = null |
||
| ) |
Set the raw (already encoded) POST data.
This function is here for two reasons: 1. For advanced user who would like to set their own data, already encoded 2. For backwards compatibilty: If someone uses the old post($data) method. this method will be used to set the encoded data.
$data can also be stream (such as file) from which the data will be read.
| string | resource | $data | |
| string | $enctype |
Definition at line 755 of file Client.php.


Set streaming for received data
| string | boolean | $streamfile | Stream file, true for temp file, false/null for no streaming |
Definition at line 884 of file Client.php.

| setUri | ( | $ | uri | ) |
Set the URI for the next request
| Zend_Uri_Http | string | $uri |
| Zend_Http_Client_Exception |
Definition at line 266 of file Client.php.


$_fileInfoDb = null [static, protected] |
Definition at line 240 of file Client.php.
$adapter = null [protected] |
Definition at line 129 of file Client.php.
$auth [protected] |
Definition at line 192 of file Client.php.
$config [protected] |
array( 'maxredirects' => 5, 'strictredirects' => false, 'useragent' => 'Zend_Http_Client', 'timeout' => 10, 'adapter' => 'Zend_Http_Client_Adapter_Socket', 'httpversion' => self::HTTP_1, 'keepalive' => false, 'storeresponse' => true, 'strict' => true, 'output_stream' => false, 'encodecookies' => true, )
Definition at line 110 of file Client.php.
$cookiejar = null [protected] |
Definition at line 209 of file Client.php.
$enctype = null [protected] |
Definition at line 171 of file Client.php.
$files = array() [protected] |
Definition at line 202 of file Client.php.
$headers = array() [protected] |
Definition at line 143 of file Client.php.
$last_request = null [protected] |
Definition at line 216 of file Client.php.
$last_response = null [protected] |
Definition at line 223 of file Client.php.
$method = self::GET [protected] |
Definition at line 150 of file Client.php.
$paramsGet = array() [protected] |
Definition at line 157 of file Client.php.
$paramsPost = array() [protected] |
Definition at line 164 of file Client.php.
$raw_post_data = null [protected] |
Definition at line 178 of file Client.php.
$redirectCounter = 0 [protected] |
Definition at line 230 of file Client.php.
$uri = null [protected] |
Definition at line 136 of file Client.php.
| const AUTH_BASIC = 'basic' |
Supported HTTP Authentication methods
Definition at line 84 of file Client.php.
Definition at line 78 of file Client.php.
| const CONTENT_LENGTH = 'Content-Length' |
Definition at line 97 of file Client.php.
| const CONTENT_TYPE = 'Content-Type' |
Content attributes
Definition at line 96 of file Client.php.
Definition at line 75 of file Client.php.
| const ENC_FORMDATA = 'multipart/form-data' |
Definition at line 103 of file Client.php.
| const ENC_URLENCODED = 'application/x-www-form-urlencoded' |
POST data encoding methods
Definition at line 102 of file Client.php.
HTTP request methods
Definition at line 71 of file Client.php.
Definition at line 74 of file Client.php.
| const HTTP_0 = '1.0' |
Definition at line 91 of file Client.php.
| const HTTP_1 = '1.1' |
HTTP protocol versions
Definition at line 90 of file Client.php.
Definition at line 79 of file Client.php.
Definition at line 77 of file Client.php.
Definition at line 72 of file Client.php.
Definition at line 73 of file Client.php.
Definition at line 76 of file Client.php.