Public Member Functions | Static Public Member Functions

RemoteRequest Class Reference

List of all members.

Public Member Functions

 __construct ($url, $method= 'GET', $timeout=180)
 __set_processor ($processor)
 set_config ($config, $value=null)
 add_header ($header)
 add_headers ($headers)
 set_body ($body)
 set_params ($params)
 set_timeout ($timeout)
 set_postdata ($name, $value=null)
 set_file ($name, $filename, $content_type=null, $override_filename=null)
 execute ()
 executed ()
 get_response_headers ()
 get_response_body ()

Static Public Member Functions

static get_contents ($url, $use_include_path=false, $context=null, $offset=0, $maxlen=-1)

Detailed Description

Generic class to make outgoing HTTP requests.

Definition at line 51 of file remoterequest.php.


Constructor & Destructor Documentation

RemoteRequest::__construct ( url,
method = 'GET',
timeout = 180 
)
Parameters:
string $url URL to request
string $method Request method to use (default 'GET')
int $timeout

For internal use only.

param int $timeuot Timeout in seconds (default 180)

Definition at line 107 of file remoterequest.php.


Member Function Documentation

RemoteRequest::__set_processor ( processor  ) 

DO NOT USE THIS FUNCTION. This function is only to be used by the test case for RemoteRequest!

Definition at line 160 of file remoterequest.php.

RemoteRequest::add_header ( header  ) 

Add a request header.

Parameters:
mixed $header The header to add, either as a string 'Name: Value' or an associative array 'name'=>'value'

Definition at line 192 of file remoterequest.php.

Referenced by __construct(), and add_headers().

RemoteRequest::add_headers ( headers  ) 

Add a list of headers.

Parameters:
array $headers List of headers to add.

Definition at line 207 of file remoterequest.php.

RemoteRequest::execute (  ) 

Actually execute the request. On success, returns true and populates the response_body and response_headers fields. On failure, throws Exception.

Exceptions:
\Exception 

Definition at line 351 of file remoterequest.php.

static RemoteRequest::get_contents ( url,
use_include_path = false,
context = null,
offset = 0,
maxlen = -1 
) [static]

Static helper function to quickly fetch an URL, with semantics similar to PHP's file_get_contents. Does not support

Returns the content on success or false if an error occurred.

Parameters:
string $url The URL to fetch
bool $use_include_path whether to search the PHP include path first (unsupported)
resource $context a stream context to use (unsupported)
int $offset how many bytes to skip from the beginning of the result
int $maxlen how many bytes to return
Returns:
string description

Definition at line 453 of file remoterequest.php.

RemoteRequest::get_response_body (  ) 

Return the response body. Raises a warning and returns '' if the request wasn't executed yet.

Todo:
This should probably just call the selected processor's method, which throws its own error.

Definition at line 393 of file remoterequest.php.

RemoteRequest::get_response_headers (  ) 

Return the response headers. Raises a warning and returns '' if the request wasn't executed yet.

Todo:
This should probably just call the selected processor's method, which throws its own error.

Definition at line 380 of file remoterequest.php.

RemoteRequest::set_body ( body  ) 

Set the request body. Only used with POST requests, will raise a warning if used with GET.

Parameters:
string $body The request body.
Exceptions:
\Exception 

Definition at line 220 of file remoterequest.php.

RemoteRequest::set_config ( config,
value = null 
)

Set adapter configuration options

Parameters:
mixed $config An array of options or a string name with a corresponding $value
mixed $value

Definition at line 171 of file remoterequest.php.

Referenced by __construct().

RemoteRequest::set_file ( name,
filename,
content_type = null,
override_filename = null 
)

set file

public

Parameters:
string $name
string $filename
string $content_type
null $override_filename
Exceptions:
\Exception 

Definition at line 280 of file remoterequest.php.

RemoteRequest::set_params ( params  ) 

Set the request query parameters (i.e., the URI's query string). Will be merged with existing query info from the URL.

Parameters:
array $params

Definition at line 234 of file remoterequest.php.

RemoteRequest::set_postdata ( name,
value = null 
)

set postdata

public

Parameters:
mixed $name
string $value

Definition at line 260 of file remoterequest.php.

RemoteRequest::set_timeout ( timeout  ) 

Set the timeout.

Parameters:
int $timeout Timeout in seconds

Definition at line 247 of file remoterequest.php.

Referenced by __construct().


The documentation for this class was generated from the following file: