PHP Класс Phergie_Plugin_Http, phergie

Автор: Phergie Development Team ([email protected])
Наследование: extends Phergie_Plugin_Abstract
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$handlers array Mapping of content types to handlers for them
$response Phergie_Plugin_Http_Response Response to the last executed HTTP request

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
parseStatusLine ( string $status ) : array Supporting method that parses the status line of an HTTP response message.

Описание методов

get() публичный Метод

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
Результат Phergie_Plugin_Http_Response Received response data

handleError() публичный Метод

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
Результат boolean Always returns TRUE to allow normal execution to continue once this method terminates

head() публичный Метод

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
Результат Phergie_Plugin_Http_Response Received response data

onLoad() публичный Метод

Initializes the handler lookup table.
public onLoad ( ) : void
Результат void

parseStatusLine() защищенный Метод

Supporting method that parses the status line of an HTTP response message.
protected parseStatusLine ( string $status ) : array
$status string Status line
Результат array Associative array containing the HTTP version, response code, and response description

post() публичный Метод

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
Результат Phergie_Plugin_Http_Response Received response data

request() публичный Метод

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
Результат Phergie_Plugin_Http_Response Object representing the response resulting from the request

setHandler() публичный Метод

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
Результат Phergie_Plugin_Http Provides a fluent interface

Описание свойств

$handlers защищенное свойство

Mapping of content types to handlers for them
protected array $handlers
Результат array

$response защищенное свойство

Response to the last executed HTTP request
protected Phergie_Plugin_Http_Response $response
Результат Phergie_Plugin_Http_Response