[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/libs/ -> MultiHttpClient.php (summary)

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: 389 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

MultiHttpClient:: (6 methods):
  __construct()
  run()
  runMulti()
  getCurlHandle()
  getCurlMulti()
  __destruct()


Class: MultiHttpClient  - X-Ref

Class to handle concurrent HTTP requests

HTTP request maps are arrays that use the following format:
- method   : GET/HEAD/PUT/POST/DELETE
- url      : HTTP/HTTPS URL
- 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( array $options )   X-Ref

param: array $options

run( array $req, array $opts = array()   X-Ref
Execute an 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 ) = $http->run( $req );
</code>
param: array $req HTTP request array
param: array $opts
return: array Response array for request

runMulti( array $reqs, array $opts = array()   X-Ref
Execute a set of HTTP(S) requests concurrently

The maps are returned by this method with the 'response' field set to a 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 ) = $req['response'];
</code>
All headers in the 'headers' field are normalized to use lower case names.
This is true for the request headers and the response headers. Integer-indexed
method/URL entries will also be changed to use the corresponding string keys.

param: array $reqs Map of HTTP request arrays
param: array $opts
return: array $reqs With response array populated for each

getCurlHandle( array &$req, array $opts = array()   X-Ref

param: array $req HTTP request map
param: array $opts
return: resource

getCurlMulti()   X-Ref
No description

__destruct()   X-Ref
No description



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