| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Guzzle\Http\Message;
|
|
|
4 |
|
|
|
5 |
use Guzzle\Common\Collection;
|
|
|
6 |
use Guzzle\Http\EntityBodyInterface;
|
|
|
7 |
use Guzzle\Http\Url;
|
|
|
8 |
|
|
|
9 |
/**
|
|
|
10 |
* Request factory used to create HTTP requests
|
|
|
11 |
*/
|
|
|
12 |
interface RequestFactoryInterface
|
|
|
13 |
{
|
|
|
14 |
const OPTIONS_NONE = 0;
|
|
|
15 |
const OPTIONS_AS_DEFAULTS = 1;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Create a new request based on an HTTP message
|
|
|
19 |
*
|
|
|
20 |
* @param string $message HTTP message as a string
|
|
|
21 |
*
|
|
|
22 |
* @return RequestInterface
|
|
|
23 |
*/
|
|
|
24 |
public function fromMessage($message);
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Create a request from URL parts as returned from parse_url()
|
|
|
28 |
*
|
|
|
29 |
* @param string $method HTTP method (GET, POST, PUT, HEAD, DELETE, etc)
|
|
|
30 |
*
|
|
|
31 |
* @param array $urlParts URL parts containing the same keys as parse_url()
|
|
|
32 |
* - scheme: e.g. http
|
|
|
33 |
* - host: e.g. www.guzzle-project.com
|
|
|
34 |
* - port: e.g. 80
|
|
|
35 |
* - user: e.g. michael
|
|
|
36 |
* - pass: e.g. rocks
|
|
|
37 |
* - path: e.g. / OR /index.html
|
|
|
38 |
* - query: after the question mark ?
|
|
|
39 |
* @param array|Collection $headers HTTP headers
|
|
|
40 |
* @param string|resource|array|EntityBodyInterface $body Body to send in the request
|
|
|
41 |
* @param string $protocol Protocol (HTTP, SPYDY, etc)
|
|
|
42 |
* @param string $protocolVersion 1.0, 1.1, etc
|
|
|
43 |
*
|
|
|
44 |
* @return RequestInterface
|
|
|
45 |
*/
|
|
|
46 |
public function fromParts(
|
|
|
47 |
$method,
|
|
|
48 |
array $urlParts,
|
|
|
49 |
$headers = null,
|
|
|
50 |
$body = null,
|
|
|
51 |
$protocol = 'HTTP',
|
|
|
52 |
$protocolVersion = '1.1'
|
|
|
53 |
);
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Create a new request based on the HTTP method
|
|
|
57 |
*
|
|
|
58 |
* @param string $method HTTP method (GET, POST, PUT, PATCH, HEAD, DELETE, ...)
|
|
|
59 |
* @param string|Url $url HTTP URL to connect to
|
|
|
60 |
* @param array|Collection $headers HTTP headers
|
|
|
61 |
* @param string|resource|array|EntityBodyInterface $body Body to send in the request
|
|
|
62 |
* @param array $options Array of options to apply to the request
|
|
|
63 |
*
|
|
|
64 |
* @return RequestInterface
|
|
|
65 |
*/
|
|
|
66 |
public function create($method, $url, $headers = null, $body = null, array $options = array());
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* Apply an associative array of options to the request
|
|
|
70 |
*
|
|
|
71 |
* @param RequestInterface $request Request to update
|
|
|
72 |
* @param array $options Options to use with the request. Available options are:
|
|
|
73 |
* "headers": Associative array of headers
|
|
|
74 |
* "query": Associative array of query string values to add to the request
|
|
|
75 |
* "body": Body of a request, including an EntityBody, string, or array when sending POST requests.
|
|
|
76 |
* "auth": Array of HTTP authentication parameters to use with the request. The array must contain the
|
|
|
77 |
* username in index [0], the password in index [2], and can optionally contain the authentication type
|
|
|
78 |
* in index [3]. The authentication types are: "Basic", "Digest", "NTLM", "Any" (defaults to "Basic").
|
|
|
79 |
* "cookies": Associative array of cookies
|
|
|
80 |
* "allow_redirects": Set to false to disable redirects
|
|
|
81 |
* "save_to": String, fopen resource, or EntityBody object used to store the body of the response
|
|
|
82 |
* "events": Associative array mapping event names to a closure or array of (priority, closure)
|
|
|
83 |
* "plugins": Array of plugins to add to the request
|
|
|
84 |
* "exceptions": Set to false to disable throwing exceptions on an HTTP level error (e.g. 404, 500, etc)
|
|
|
85 |
* "params": Set custom request data parameters on a request. (Note: these are not query string parameters)
|
|
|
86 |
* "timeout": Float describing the timeout of the request in seconds
|
|
|
87 |
* "connect_timeout": Float describing the number of seconds to wait while trying to connect. Use 0 to wait
|
|
|
88 |
* indefinitely.
|
|
|
89 |
* "verify": Set to true to enable SSL cert validation (the default), false to disable, or supply the path
|
|
|
90 |
* to a CA bundle to enable verification using a custom certificate.
|
|
|
91 |
* "cert": Set to a string to specify the path to a file containing a PEM formatted certificate. If a
|
|
|
92 |
* password is required, then set an array containing the path to the PEM file followed by the the
|
|
|
93 |
* password required for the certificate.
|
|
|
94 |
* "ssl_key": Specify the path to a file containing a private SSL key in PEM format. If a password is
|
|
|
95 |
* required, then set an array containing the path to the SSL key followed by the password required for
|
|
|
96 |
* the certificate.
|
|
|
97 |
* "proxy": Specify an HTTP proxy (e.g. "http://username:password@192.168.16.1:10")
|
|
|
98 |
* "debug": Set to true to display all data sent over the wire
|
|
|
99 |
* @param int $flags Bitwise flags to apply when applying the options to the request. Defaults to no special
|
|
|
100 |
* options. `1` (OPTIONS_AS_DEFAULTS): When specified, options will only update a request when
|
|
|
101 |
* the value does not already exist on the request. This is only supported by "query" and
|
|
|
102 |
* "headers". Other bitwise options may be added in the future.
|
|
|
103 |
*/
|
|
|
104 |
public function applyOptions(RequestInterface $request, array $options = array(), $flags = self::OPTIONS_NONE);
|
|
|
105 |
}
|