PHP Class Phergie_Plugin_Http, phergie

Author: Phergie Development Team ([email protected])
Inheritance: extends Phergie_Plugin_Abstract
Mostrar archivo Open project: phergie/phergie Class Usage Examples

Protected Properties

Property Type Description
$handlers array Mapping of content types to handlers for them
$response Phergie_Plugin_Http_Response Response to the last executed HTTP request

Public Methods

Method Description
get ( string $url, array $query = [], array $context = [] ) : Phergie_Plugin_Http_Response Performs a GET request.
handleError ( integer $errno, string $errstr, string $errfile, string $errline ) : boolean Supporting method that acts as an error handler to intercept HTTP responses resulting in PHP-level errors.
head ( string $url, array $query = [], array $context = [] ) : Phergie_Plugin_Http_Response Performs a HEAD request.
onLoad ( ) : void Initializes the handler lookup table.
post ( string $url, array $query = [], array $post = [], array $context = [] ) : Phergie_Plugin_Http_Response Performs a POST request.
request ( string $url, array $context ) : Phergie_Plugin_Http_Response Supporting method that executes a request and handles the response.
setHandler ( string $type, callback $callback ) : Phergie_Plugin_Http Sets a handler callback for a content type, which is called when a response of that content type is received to perform any needed transformations on the response body content before storing it in the response object. Note that the calling plugin is responsible for indicating any dependencies related to specified handler callbacks.

Protected Methods

Method Description
parseStatusLine ( string $status ) : array Supporting method that parses the status line of an HTTP response message.

Method Details

get() public method

Performs a GET request.
public get ( string $url, array $query = [], array $context = [] ) : Phergie_Plugin_Http_Response
$url string URL for the request
$query array Optional associative array of parameters constituting the URL query string if $url has none
$context array Optional associative array of additional stream context parameters
return Phergie_Plugin_Http_Response Received response data

handleError() public method

Supporting method that acts as an error handler to intercept HTTP responses resulting in PHP-level errors.
public handleError ( integer $errno, string $errstr, string $errfile, string $errline ) : boolean
$errno integer Level of the error raised
$errstr string Error message
$errfile string Name of the file in which the error was raised
$errline string Line number on which the error was raised
return boolean Always returns TRUE to allow normal execution to continue once this method terminates

head() public method

Performs a HEAD request.
public head ( string $url, array $query = [], array $context = [] ) : Phergie_Plugin_Http_Response
$url string URL for the request
$query array Optional associative array of parameters constituting the URL query string if $url has none
$context array Optional associative array of additional stream context parameters
return Phergie_Plugin_Http_Response Received response data

onLoad() public method

Initializes the handler lookup table.
public onLoad ( ) : void
return void

parseStatusLine() protected method

Supporting method that parses the status line of an HTTP response message.
protected parseStatusLine ( string $status ) : array
$status string Status line
return array Associative array containing the HTTP version, response code, and response description

post() public method

Performs a POST request.
public post ( string $url, array $query = [], array $post = [], array $context = [] ) : Phergie_Plugin_Http_Response
$url string URL for the request
$query array Optional associative array of parameters constituting the URL query string if $url has none
$post array Optional associative array of parameters constituting the POST request body if it is using the traditional URL-encoded format
$context array Optional associative array of additional stream context parameters
return Phergie_Plugin_Http_Response Received response data

request() public method

Supporting method that executes a request and handles the response.
public request ( string $url, array $context ) : Phergie_Plugin_Http_Response
$url string URL to request
$context array Associative array of stream context parameters
return Phergie_Plugin_Http_Response Object representing the response resulting from the request

setHandler() public method

Sets a handler callback for a content type, which is called when a response of that content type is received to perform any needed transformations on the response body content before storing it in the response object. Note that the calling plugin is responsible for indicating any dependencies related to specified handler callbacks.
public setHandler ( string $type, callback $callback ) : Phergie_Plugin_Http
$type string PCRE regular expression (without delimiters) that matches one or more MIME types
$callback callback Callback to execute when a response of a content type matched by $type is encountered
return Phergie_Plugin_Http Provides a fluent interface

Property Details

$handlers protected_oe property

Mapping of content types to handlers for them
protected array $handlers
return array

$response protected_oe property

Response to the last executed HTTP request
protected Phergie_Plugin_Http_Response $response
return Phergie_Plugin_Http_Response