MediaWiki  REL1_24
VirtualRESTServiceClient Class Reference

Virtual HTTP service client loosely styled after a Virtual File System. More...

Collaboration diagram for VirtualRESTServiceClient:

List of all members.

Public Member Functions

 __construct (MultiHttpClient $http)
 getMountAndService ($path)
 Get the prefix and service that a virtual path is serviced by.
 mount ($prefix, VirtualRESTService $instance)
 Map a prefix to service handler.
 run (array $req)
 Execute a virtual HTTP(S) request.
 runMulti (array $reqs)
 Execute a set of virtual HTTP(S) requests concurrently.
 unmount ($prefix)
 Unmap a prefix to service handler.

Public Attributes

const VALID_MOUNT_REGEX = '#^/[0-9a-z]+/([0-9a-z]+/)*$#'

Protected Attributes

MultiHttpClient $http
 *
Array $instances = array()
 Map of (prefix => VirtualRESTService) *.

Detailed Description

Virtual HTTP service client loosely styled after a Virtual File System.

Services can be mounted on path prefixes so that virtual HTTP operations against sub-paths will map to those services. Operations can actually be done using HTTP messages over the wire or may simple be emulated locally.

Virtual HTTP request maps are arrays that use the following format:

  • method : GET/HEAD/PUT/POST/DELETE
  • url : HTTP/HTTPS URL or virtual service path with a registered prefix
  • query : <query parameter field/value associative array> (uses RFC 3986)
  • headers : <header name/value associative array>
  • body : source to get the HTTP request body from; this can simply be a string (always), a resource for PUT requests, and a field/value array for POST request; array bodies are encoded as multipart/form-data and strings use application/x-www-form-urlencoded (headers sent automatically)
  • stream : resource to stream the HTTP response body to Request maps can use integer index 0 instead of 'method' and 1 instead of 'url'.
Author:
Aaron Schulz
Since:
1.23

Definition at line 46 of file VirtualRESTServiceClient.php.


Constructor & Destructor Documentation


Member Function Documentation

Get the prefix and service that a virtual path is serviced by.

Parameters:
string$path
Returns:
array (prefix,VirtualRESTService) or (null,null) if none found

Definition at line 94 of file VirtualRESTServiceClient.php.

VirtualRESTServiceClient::mount ( prefix,
VirtualRESTService instance 
)

Map a prefix to service handler.

Parameters:
string$prefixVirtual path
VirtualRESTService$instance

Definition at line 65 of file VirtualRESTServiceClient.php.

Execute a virtual HTTP(S) request.

This method returns a response map of:

  • code : HTTP response code or 0 if there was a serious cURL error
  • reason : HTTP response reason (empty if there was a serious cURL error)
  • headers : <header name/value associative array>
  • body : HTTP response body or resource (if "stream" was set)
  • err : Any cURL error string The map also stores integer-indexed copies of these values. This lets callers do: list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $client->run( $req );
    Parameters:
    array$reqVirtual HTTP request array
    Returns:
    array Response array for request

Definition at line 134 of file VirtualRESTServiceClient.php.

Execute a set of virtual HTTP(S) requests concurrently.

A map of requests keys to response maps is returned. Each response map has:

  • code : HTTP response code or 0 if there was a serious cURL error
  • reason : HTTP response reason (empty if there was a serious cURL error)
  • headers : <header name/value associative array>
  • body : HTTP response body or resource (if "stream" was set)
  • err : Any cURL error string The map also stores integer-indexed copies of these values. This lets callers do: list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $responses[0];
Parameters:
array$reqMap of Virtual HTTP request arrays
Returns:
array $reqs Map of corresponding response values with the same keys/order

Definition at line 156 of file VirtualRESTServiceClient.php.

Unmap a prefix to service handler.

Parameters:
string$prefixVirtual path

Definition at line 79 of file VirtualRESTServiceClient.php.


Member Data Documentation

MultiHttpClient VirtualRESTServiceClient::$http [protected]

*

Definition at line 47 of file VirtualRESTServiceClient.php.

Array VirtualRESTServiceClient::$instances = array() [protected]

Map of (prefix => VirtualRESTService) *.

Definition at line 48 of file VirtualRESTServiceClient.php.

const VirtualRESTServiceClient::VALID_MOUNT_REGEX = '#^/[0-9a-z]+/([0-9a-z]+/)*$#'

Definition at line 50 of file VirtualRESTServiceClient.php.


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