Class RemoteRequest

Description

Generic class to make outgoing HTTP requests.

Located in /system/classes/remoterequest.php (line 27)


	
			
Method Summary
static string get_contents (string $url, [bool $use_include_path = FALSE], [resource $context = NULL], [int $offset = 0], [int $maxlen = -1])
RemoteRequest __construct (string $url, [string $method = 'GET'], [ $timeout = 180], int $timeuot)
void add_header (mixed $header)
void add_headers (array $headers)
void execute ()
void executed ()
void set_body (string $body)
void set_params (array $params)
void set_timeout (int $timeout)
void __set_processor ( $processor)
Methods
static method get_contents (line 259)

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.

  • return: description
  • access: public
static string get_contents (string $url, [bool $use_include_path = FALSE], [resource $context = NULL], [int $offset = 0], [int $maxlen = -1])
  • 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
Constructor __construct (line 48)
  • access: public
RemoteRequest __construct (string $url, [string $method = 'GET'], [ $timeout = 180], int $timeuot)
  • string $url: URL to request
  • string $method: Request method to use (default 'GET')
  • int $timeuot: Timeout in seconds (default 180)
  • $timeout
add_header (line 79)

Add a request header.

  • access: public
void add_header (mixed $header)
  • mixed $header: The header to add, either as a string 'Name: Value' or an associative array 'name'=>'value'
add_headers (line 94)

Add a list of headers.

  • access: public
void add_headers (array $headers)
  • array $headers: List of headers to add.
execute (line 161)

Actually execute the request.

On success, returns TRUE and populates the response_body and response_headers fields. On failure, throws error.

  • access: public
void execute ()
executed (line 182)
  • access: public
void executed ()
get_response_body (line 200)

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

  • access: public
void get_response_body ()
get_response_headers (line 189)

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

  • access: public
void get_response_headers ()
set_body (line 106)

Set the request body.

Only used with POST requests, will raise a warning if used with GET.

  • access: public
void set_body (string $body)
  • string $body: The request body.
set_params (line 119)

Set the request query parameters (i.e., the URI's query string).

Will be merged with existing query info from the URL.

  • access: public
void set_params (array $params)
  • array $params
set_timeout (line 131)

Set the timeout.

  • access: public
void set_timeout (int $timeout)
  • int $timeout: Timeout in seconds
__set_processor (line 70)

DO NOT USE THIS FUNCTION.

This function is only to be used by the test case for RemoteRequest!

  • access: public
void __set_processor ( $processor)
  • $processor

Documentation generated on Thu, 30 Oct 2008 20:31:25 +0100 by phpDocumentor 1.3.2