[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/libs/virtualrest/ -> VirtualRESTServiceClient.php (summary)

Virtual HTTP service client This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 289 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

VirtualRESTServiceClient:: (6 methods):
  __construct()
  mount()
  unmount()
  getMountAndService()
  run()
  runMulti()


Class: VirtualRESTServiceClient  - X-Ref

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'.

__construct( MultiHttpClient $http )   X-Ref

param: MultiHttpClient $http

mount( $prefix, VirtualRESTService $instance )   X-Ref
Map a prefix to service handler

param: string $prefix Virtual path
param: VirtualRESTService $instance

unmount( $prefix )   X-Ref
Unmap a prefix to service handler

param: string $prefix Virtual path

getMountAndService( $path )   X-Ref
Get the prefix and service that a virtual path is serviced by

param: string $path
return: array (prefix,VirtualRESTService) or (null,null) if none found

run( array $req )   X-Ref
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:
<code>
list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $client->run( $req );
</code>
param: array $req Virtual HTTP request array
return: array Response array for request

runMulti( array $reqs )   X-Ref
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:
<code>
list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $responses[0];
</code>

param: array $req Map of Virtual HTTP request arrays
return: array $reqs Map of corresponding response values with the same keys/order



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1