3 * Extended HTTP support. Again.
5 * * Introduces the http namespace.
6 * * PHP stream based message bodies.
7 * * Encapsulated env request/response.
8 * * Modular client support.
13 * The HTTP client. See http\Client\Curl's [options](http/Client/Curl#Options:) which is the only driver currently supported.
15 class Client
implements \SplSubject
, \Countable
{
17 * Debug callback's $data contains human readable text.
21 * Debug callback's $data contains data received.
25 * Debug callback's $data contains data sent.
29 * Debug callback's $data contains headers.
31 const DEBUG_HEADER
= 16;
33 * Debug callback's $data contains a body part.
35 const DEBUG_BODY
= 32;
37 * Debug callback's $data contains SSL data.
44 * @var SplObjectStorage
46 private $observers = NULL;
53 protected $options = NULL;
55 * Request/response history.
60 protected $history = NULL;
62 * Whether to record history in http\Client::$history.
67 public $recordHistory = false;
69 * Create a new HTTP client.
71 * Currently only "curl" is supported as a $driver, and used by default.
72 * Persisted resources identified by $persistent_handle_id will be re-used if available.
74 * @param string $driver The HTTP client driver to employ. Currently only the default driver, "curl", is supported.
75 * @param string $persistent_handle_id If supplied, created curl handles will be persisted with this identifier for later reuse.
76 * @throws http\Exception\InvalidArgumentException
77 * @throws http\Exception\UnexpectedValueException
78 * @throws http\Exception\RuntimeException
80 function __construct($driver = NULL, $persistent_handle_id = NULL) {}
83 * See http\Client::setCookies().
85 * @param array $cookies Custom cookies to add.
86 * @throws http\Exception\InvalidArgumentException
87 * @return http\Client self.
89 function addCookies($cookies = NULL) {}
91 * Add specific SSL options.
92 * See http\Client::setSslOptions(), http\Client::setOptions() and http\Client\Curl\$ssl options.
94 * @param array $ssl_options Add this SSL options.
95 * @throws http\Exceptionc\InvalidArgumentException
96 * @return http\Client self.
98 function addSslOptions($ssl_options = NULL) {}
100 * Implements SplSubject. Attach another observer.
101 * Attached observers will be notified with progress of each transfer.
103 * @param SplObserver $observer An implementation of SplObserver.
104 * @throws http\Exception\InvalidArgumentException
105 * @throws http\Exception\UnexpectedValueException
106 * @return http\Client self.
108 function attach($observer) {}
110 * Configure the client's low level options.
113 * > This method has been added in v2.3.0.
115 * @param array $configuration Key/value pairs of low level options.
116 * See f.e. the [configuration options for the Curl driver](http/Client/Curl#Configuration:).
117 * @throws http\Exception\InvalidArgumentException
118 * @throws http\Exception\UnexpectedValueException
119 * @return http\Client self.
121 function configure($configuration) {}
123 * Implements Countable. Retrieve the number of enqueued requests.
126 * > The enqueued requests are counted without regard whether they are finished or not.
128 * @return int number of enqueued requests.
132 * Dequeue the http\Client\Request $request.
134 * See http\Client::requeue(), if you want to requeue the request, instead of calling http\Client::dequeue() and then http\Client::enqueue().
136 * @param http\Client\Request $request The request to cancel.
137 * @throws http\Exception\InvalidArgumentException
138 * @throws http\Exception\BadMethodCallException
139 * @throws http\Exception\RuntimeException
140 * @return http\Client self.
142 function dequeue($request) {}
144 * Implements SplSubject. Detach $observer, which has been previously attached.
146 * @param SplObserver $observer Previously attached instance of SplObserver implementation.
147 * @throws http\Exception\InvalidArgumentException
148 * @throws http\Exception\UnexpectedValueException
149 * @return http\Client self.
151 function detach($observer) {}
153 * Enable usage of an event library like libevent, which might improve performance with big socket sets.
156 * > This method has been deprecated in 2.3.0, please use http\Client::configure() instead.
158 * @param bool $enable Whether to enable libevent usage.
159 * @throws http\Exception\InvalidArgumentException
160 * @throws http\Exception\UnexpectedValueException
161 * @return http\Client self.
164 function enableEvents($enable = true) {}
166 * Enable sending pipelined requests to the same host if the driver supports it.
169 * > This method has been deprecated in 2.3.0, please use http\Client::configure() instead.
171 * @param bool $enable Whether to enable pipelining.
172 * @throws http\Exception\InvalidArgumentException
173 * @throws http\Exception\UnexpectedValueException
174 * @return http\Client self.
177 function enablePipelining($enable = true) {}
179 * Add another http\Client\Request to the request queue.
180 * If the optional callback $cb returns true, the request will be automatically dequeued.
183 * > The http\Client\Response object resulting from the request is always stored
184 * > internally to be retreived at a later time, __even__ when $cb is used.
186 * > If you are about to send a lot of requests and do __not__ need the response
187 * > after executing the callback, you can use http\Client::getResponse() within
188 * > the callback to keep the memory usage level as low as possible.
190 * See http\Client::dequeue() and http\Client::send().
192 * @param http\Client\Request $request The request to enqueue.
193 * @param callable $cb A callback to automatically call when the request has finished.
194 * @throws http\Exception\InvalidArgumentException
195 * @throws http\Exception\BadMethodCallException
196 * @throws http\Exception\RuntimeException
197 * @return http\Client self.
199 function enqueue($request, $cb = NULL) {}
201 * Get a list of available configuration options and their default values.
203 * See f.e. the [configuration options for the Curl driver](http/Client/Curl#Configuration:).
205 * @throws http\Exception\InvalidArgumentException
206 * @return array list of key/value pairs of available configuarion options and their default values.
208 function getAvailableConfiguration() {}
210 * List available drivers.
212 * @return array list of supported drivers.
214 function getAvailableDrivers() {}
216 * Retrieve a list of available request options and their default values.
218 * See f.e. the [request options for the Curl driver](http/Client/Curl#Options:).
220 * @throws http\Exception\InvalidArgumentException
221 * @return array list of key/value pairs of available request options and their default values.
223 function getAvailableOptions() {}
225 * Get priorly set custom cookies.
226 * See http\Client::setCookies().
228 * @return array custom cookies.
230 function getCookies() {}
232 * Simply returns the http\Message chain representing the request/response history.
235 * > The history is only recorded while http\Client::$recordHistory is true.
237 * @throws http\Exception\InvalidArgumentException
238 * @return http\Message the request/response message chain representing the client's history.
240 function getHistory() {}
242 * Returns the SplObjectStorage holding attached observers.
244 * @throws http\Exception\InvalidArgumentException
245 * @throws http\Exception\UnexpectedValueException
246 * @return SplObjectStorage observer storage.
248 function getObservers() {}
250 * Get priorly set options.
251 * See http\Client::setOptions().
253 * @return array options.
255 function getOptions() {}
257 * Retrieve the progress information for $request.
259 * @param http\Client\Request $request The request to retrieve the current progress information for.
260 * @throws http\Exception\InvalidArgumentException
261 * @throws http\Exception\UnexpectedValueException
262 * @return object|NULL stdClass instance holding progress information.
263 * or NULL if $request is not enqueued.
265 function getProgressInfo($request) {}
267 * Retrieve the corresponding reponse of an already finished request, or the last received response if $request is not set.
270 * > If $request is NULL, then the response is removed from the internal storage (stack-like operation).
272 * @param http\Client\Request $request The request to fetch the stored response for.
273 * @throws http\Exception\InvalidArgumentException
274 * @throws http\Exception\UnexpectedValueException
275 * @return http\Client\Response|NULL the stored response for the request, or the last that was received.
276 * or NULL if no more response was available to pop, when no $request was given.
278 function getResponse($request = NULL) {}
280 * Retrieve priorly set SSL options.
281 * See http\Client::getOptions() and http\Client::setSslOptions().
283 * @return array SSL options.
285 function getSslOptions() {}
287 * Get transfer related informatioin for a running or finished request.
289 * @param http\Client\Request $request The request to probe for transfer info.
290 * @throws http\Exception\InvalidArgumentException
291 * @throws http\Exception\UnexpectedValueException
292 * @return object stdClass instance holding transfer related information.
294 function getTransferInfo($request) {}
296 * Implements SplSubject. Notify attached observers about progress with $request.
298 * @param http\Client\Request $request The request to notify about.
299 * @param object $progress stdClass instance holding progress information.
300 * @throws http\Exception\InvalidArgumentException
301 * @throws http\Exception\UnexpectedValueException
302 * @return http\Client self.
304 function notify($request = NULL, $progress = NULL) {}
306 * Perform outstanding transfer actions.
307 * See http\Client::wait() for the completing interface.
309 * @return bool true if there are more transfers to complete.
313 * Requeue an http\Client\Request.
315 * The difference simply is, that this method, in contrast to http\Client::enqueue(), does not throw an http\Exception when the request to queue is already enqueued and dequeues it automatically prior enqueueing it again.
317 * @param http\Client\Request $request The request to queue.
318 * @throws http\Exception\InvalidArgumentException
319 * @throws http\Exception\RuntimeException
320 * @return http\Client self.
322 function requeue($request) {}
324 * Reset the client to the initial state.
326 * @return http\Client self.
330 * Send all enqueued requests.
331 * See http\Client::once() and http\Client::wait() for a more fine grained interface.
333 * @throws http\Exception\InvalidArgumentException
334 * @throws http\Exception\RuntimeException
335 * @return http\Client self.
339 * Set custom cookies.
340 * See http\Client::addCookies() and http\Client::getCookies().
342 * @param array $cookies Set the custom cookies to this array.
343 * @throws http\Exception\InvalidArgumentException
344 * @return http\Client self.
346 function setCookies($cookies = NULL) {}
348 * Set client debugging callback.
351 * > This method has been added in v2.6.0, resp. v3.1.0.
353 * @param callable $callback as function(http\Client $c, http\Client\Request $r, int $type, string $data)
354 * The debug callback. For $type see http\Client::DEBUG_* constants.
355 * @throws http\Exception\InvalidArgumentException
356 * @return http\Client self.
358 function setDebug($callback) {}
360 * Set client options.
361 * See http\Client\Curl.
364 * > Only options specified prior enqueueing a request are applied to the request.
366 * @param array $options The options to set.
367 * @throws http\Exception\InvalidArgumentException
368 * @return http\Client self.
370 function setOptions($options = NULL) {}
372 * Specifically set SSL options.
373 * See http\Client::setOptions() and http\Client\Curl\$ssl options.
375 * @param array $ssl_options Set SSL options to this array.
376 * @throws http\Exception\InvalidArgumentException
377 * @return http\Client self.
379 function setSslOptions($ssl_options = NULL) {}
381 * Wait for $timeout seconds for transfers to provide data.
382 * This is the completion call to http\Client::once().
384 * @param float $timeout Seconds to wait for data on open sockets.
385 * @return bool success.
387 function wait($timeout = 0) {}
390 * A class representing a list of cookies with specific attributes.
394 * Do not decode cookie contents.
398 * The cookies' flags have the secure attribute set.
402 * The cookies' flags have the httpOnly attribute set.
406 * Create a new cookie list.
408 * @param mixed $cookies The string or list of cookies to parse or set.
409 * @param int $flags Parse flags. See http\Cookie::PARSE_* constants.
410 * @param array $allowed_extras List of extra attribute names to recognize.
411 * @throws http\Exception\InvalidArgumentException
412 * @throws http\Exception\RuntimeException
414 function __construct($cookies = NULL, $flags = 0, $allowed_extras = NULL) {}
416 * String cast handler. Alias of http\Cookie::toString().
418 * @return string the cookie(s) represented as string.
420 function __toString() {}
423 * See http\Cookie::setCookie() and http\Cookie::addCookies().
425 * @param string $cookie_name The key of the cookie.
426 * @param string $cookie_value The value of the cookie.
427 * @throws http\Exception\InvalidArgumentException
428 * @return http\Cookie self.
430 function addCookie($cookie_name, $cookie_value) {}
432 * (Re)set the cookies.
433 * See http\Cookie::setCookies().
435 * @param array $cookies Add cookies of this array of form ["name" => "value"].
436 * @throws http\Exception\InvalidArgumentException
437 * @return http\Cookie self.
439 function addCookies($cookies) {}
441 * Add an extra attribute to the cookie list.
442 * See http\Cookie::setExtra().
444 * @param string $extra_name The key of the extra attribute.
445 * @param string $extra_value The value of the extra attribute.
446 * @throws http\Exception\InvalidArgumentException
447 * @return http\Cookie self.
449 function addExtra($extra_name, $extra_value) {}
451 * Add several extra attributes.
452 * See http\Cookie::addExtra().
454 * @param array $extras A list of extra attributes of the form ["key" => "value"].
455 * @throws http\Exception\InvalidArgumentException
456 * @return http\Cookie self.
458 function addExtras($extras) {}
460 * Retrieve a specific cookie value.
461 * See http\Cookie::setCookie().
463 * @param string $cookie_name The key of the cookie to look up.
464 * @return string|NULL the cookie value.
465 * or NULL if $cookie_name could not be found.
467 function getCookie($cookie_name) {}
469 * Get the list of cookies.
470 * See http\Cookie::setCookies().
472 * @return array the list of cookies of form ["name" => "value"].
474 function getCookies() {}
476 * Retrieve the effective domain of the cookie list.
477 * See http\Cookie::setDomain().
479 * @return string the effective domain.
481 function getDomain() {}
483 * Get the currently set expires attribute.
484 * See http\Cookie::setExpires().
487 * > A return value of -1 means that the attribute is not set.
489 * @return int the currently set expires attribute as seconds since the epoch.
491 function getExpires() {}
493 * Retrieve an extra attribute.
494 * See http\Cookie::setExtra().
496 * @param string $name The key of the extra attribute.
497 * @return string the value of the extra attribute.
499 function getExtra($name) {}
501 * Retrieve the list of extra attributes.
502 * See http\Cookie::setExtras().
504 * @return array the list of extra attributes of the form ["key" => "value"].
506 function getExtras() {}
508 * Get the currently set flags.
509 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
511 * @return int the currently set flags bitmask.
513 function getFlags() {}
515 * Get the currently set max-age attribute of the cookie list.
516 * See http\Cookie::setMaxAge().
519 * > A return value of -1 means that the attribute is not set.
521 * @return int the currently set max-age.
523 function getMaxAge() {}
525 * Retrieve the path the cookie(s) of this cookie list are effective at.
526 * See http\Cookie::setPath().
528 * @return string the effective path.
530 function getPath() {}
533 * See http\Cookie::addCookie() and http\Cookie::setCookies().
536 * > The cookie will be deleted from the list if $cookie_value is NULL.
538 * @param string $cookie_name The key of the cookie.
539 * @param string $cookie_value The value of the cookie.
540 * @throws http\Exception\InvalidArgumentException
541 * @return http\Cookie self.
543 function setCookie($cookie_name, $cookie_value) {}
545 * (Re)set the cookies.
546 * See http\Cookie::addCookies().
548 * @param array $cookies Set the cookies to this array.
549 * @throws http\Exception\InvalidArgumentException
550 * @return http\Cookie self.
552 function setCookies($cookies = NULL) {}
554 * Set the effective domain of the cookie list.
555 * See http\Cookie::setPath().
557 * @param string $value The domain the cookie(s) belong to.
558 * @throws http\Exception\InvalidArgumentException
559 * @return http\Cookie self.
561 function setDomain($value = NULL) {}
563 * Set the traditional expires timestamp.
564 * See http\Cookie::setMaxAge() for a safer alternative.
566 * @param int $value The expires timestamp as seconds since the epoch.
567 * @throws http\Exception\InvalidArgumentException
568 * @return http\Cookie self.
570 function setExpires($value = -1) {}
572 * (Re)set an extra attribute.
573 * See http\Cookie::addExtra().
576 * > The attribute will be removed from the extras list if $extra_value is NULL.
578 * @param string $extra_name The key of the extra attribute.
579 * @param string $extra_value The value of the extra attribute.
580 * @throws http\Exception\InvalidArgumentException
581 * @return http\Cookie self.
583 function setExtra($extra_name, $extra_value = NULL) {}
585 * (Re)set the extra attributes.
586 * See http\Cookie::addExtras().
588 * @param array $extras Set the extra attributes to this array.
589 * @throws http\Exception\InvalidArgumentException
590 * @return http\Cookie self.
592 function setExtras($extras = NULL) {}
594 * Set the flags to specified $value.
595 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
597 * @param int $value The new flags bitmask.
598 * @throws http\Exception\InvalidArgumentException
599 * @return http\Cookie self.
601 function setFlags($value = 0) {}
603 * Set the maximum age the cookie may have on the client side.
604 * This is a client clock departure safe alternative to the "expires" attribute.
605 * See http\Cookie::setExpires().
607 * @param int $value The max-age in seconds.
608 * @throws http\Exception\InvalidArgumentException
609 * @return http\Cookie self.
611 function setMaxAge($value = -1) {}
613 * Set the path the cookie(s) of this cookie list should be effective at.
614 * See http\Cookie::setDomain().
616 * @param string $path The URL path the cookie(s) should take effect within.
617 * @throws http\Exception\InvalidArgumentException
618 * @return http\Cookie self.
620 function setPath($path = NULL) {}
622 * Get the cookie list as array.
624 * @return array the cookie list as array.
626 function toArray() {}
628 * Retrieve the string representation of the cookie list.
629 * See http\Cookie::toArray().
631 * @return string the cookie list as string.
633 function toString() {}
638 namespace http\Encoding
;
641 * The http\Env class provides static methods to manipulate and inspect the server's current request's HTTP environment.
645 * Retreive the current HTTP request's body.
647 * @throws http\Exception\InvalidArgumentException
648 * @throws http\Exception\UnexpectedValueException
649 * @return http\Message\Body instance representing the request body
651 function getRequestBody() {}
653 * Retrieve one or all headers of the current HTTP request.
655 * @return NULL|string|array if $header_name was not found
656 * or string the compound header when $header_name was found
657 * or array of all headers if $header_name was not specified
659 function getRequestHeader() {}
661 * Get the HTTP response code to send.
663 * @return int the HTTP response code.
665 function getResponseCode() {}
667 * Get one or all HTTP response headers to be sent.
669 * @return string|NULL|array the compound value of the response header to send
670 * or NULL if the header was not found
671 * or array of all response headers, if $header_name was not specified
673 function getResponseHeader() {}
675 * Retrieve a list of all known HTTP response status.
677 * @return array mapping of the form \[
679 * int $code => string $status
683 function getResponseStatusForAllCodes() {}
685 * Retrieve the string representation of specified HTTP response code.
687 * @return string|empty the HTTP response status message
688 * or empty string, if no message for this code was found
690 function getResponseStatusForCode() {}
692 * Generic negotiator. For specific client negotiation see http\Env::negotiateContentType() and related methods.
695 * > The first elemement of $supported serves as a default if no operand matches.
697 * @param string $params HTTP header parameter's value to negotiate.
698 * @param array $supported List of supported negotiation operands.
699 * @param string $prim_typ_sep A "primary type separator", i.e. that would be a hyphen for content language negotiation (en-US, de-DE, etc.).
700 * @return NULL|string if negotiation fails.
701 * or string the closest match negotiated, or the default (first entry of $supported).
703 function negotiate($params, $supported, $prim_typ_sep = NULL) {}
705 * Negotiate the client's preferred character set.
708 * > The first elemement of $supported character sets serves as a default if no character set matches.
710 * @param array $supported List of supported content character sets.
711 * @return NULL|string if negotiation fails.
712 * or string the negotiated character set.
714 function negotiateCharset($supported) {}
716 * Negotiate the client's preferred MIME content type.
719 * > The first elemement of $supported content types serves as a default if no content-type matches.
721 * @param array $supported List of supported MIME content types.
722 * @return NULL|string if negotiation fails.
723 * or string the negotiated content type.
725 function negotiateContentType($supported) {}
727 * Negotiate the client's preferred encoding.
730 * > The first elemement of $supported encodings serves as a default if no encoding matches.
732 * @param array $supported List of supported content encodings.
733 * @return NULL|string if negotiation fails.
734 * or string the negotiated encoding.
736 function negotiateEncoding($supported) {}
738 * Negotiate the client's preferred language.
741 * > The first elemement of $supported languages serves as a default if no language matches.
743 * @param array $supported List of supported content languages.
744 * @return NULL|string if negotiation fails.
745 * or string the negotiated language.
747 function negotiateLanguage($supported) {}
749 * Set the HTTP response code to send.
751 * @param int $code The HTTP response status code.
752 * @return bool Success.
754 function setResponseCode($code) {}
756 * Set a response header, either replacing a prior set header, or appending the new header value, depending on $replace.
758 * If no $header_value is specified, or $header_value is NULL, then a previously set header with the same key will be deleted from the list.
760 * If $response_code is not 0, the response status code is updated accordingly.
762 * @return bool Success.
764 function setResponseHeader() {}
767 * The http extension's Exception interface.
769 * Use it to catch any Exception thrown by pecl/http.
771 * The individual exception classes extend their equally named native PHP extensions, if such exist, and implement this empty interface. For example the http\Exception\BadMethodCallException extends SPL's BadMethodCallException.
773 interface Exception
{
776 * The http\Header class provides methods to manipulate, match, negotiate and serialize HTTP headers.
778 class Header
implements \Serializable
{
780 * None of the following match constraints applies.
782 const MATCH_LOOSE
= 0;
784 * Perform case sensitive matching.
786 const MATCH_CASE
= 1;
788 * Match only on word boundaries (according by CType alpha-numeric).
790 const MATCH_WORD
= 16;
792 * Match the complete string.
794 const MATCH_FULL
= 32;
796 * Case sensitively match the full string (same as MATCH_CASE|MATCH_FULL).
798 const MATCH_STRICT
= 33;
800 * The name of the HTTP header.
807 * The value of the HTTP header.
812 public $value = NULL;
814 * Create an http\Header instance for use of simple matching or negotiation. If the value of the header is an array it may be compounded to a single comma separated string.
816 * @param string $name The HTTP header name.
817 * @param mixed $value The value of the header.
821 function __construct($name = NULL, $value = NULL) {}
823 * String cast handler. Alias of http\Header::serialize().
825 * @return string the serialized form of the HTTP header (i.e. "Name: value").
827 function __toString() {}
829 * Create a parameter list out of the HTTP header value.
831 * @param mixed $ps The parameter separator(s).
832 * @param mixed $as The argument separator(s).
833 * @param mixed $vs The value separator(s).
834 * @param int $flags The modus operandi. See http\Params constants.
835 * @return http\Params instance
837 function getParams($ps = NULL, $as = NULL, $vs = NULL, $flags = NULL) {}
839 * Match the HTTP header's value against provided $value according to $flags.
841 * @param string $value The comparison value.
842 * @param int $flags The modus operandi. See http\Header constants.
843 * @return bool whether $value matches the header value according to $flags.
845 function match($value, $flags = NULL) {}
847 * Negotiate the header's value against a list of supported values in $supported.
848 * Negotiation operation is adopted according to the header name, i.e. if the
849 * header being negotiated is Accept, then a slash is used as primary type
850 * separator, and if the header is Accept-Language respectively, a hyphen is
854 * > The first elemement of $supported serves as a default if no operand matches.
856 * @param array $supported The list of supported values to negotiate.
857 * @return NULL|string if negotiation fails.
858 * or string the closest match negotiated, or the default (first entry of $supported).
860 function negotiate($supported) {}
862 * Parse HTTP headers.
863 * See also http\Header\Parser.
865 * @param string $header The complete string of headers.
866 * @param string $header_class A class extending http\Header.
867 * @return array|false of parsed headers, where the elements are instances of $header_class if specified.
868 * or false if parsing fails.
870 function parse($header, $header_class = NULL) {}
872 * Implements Serializable.
874 * @return string serialized representation of HTTP header (i.e. "Name: value")
876 function serialize() {}
878 * Convenience method. Alias of http\Header::serialize().
880 * @return string the serialized form of the HTTP header (i.e. "Name: value").
882 function toString() {}
884 * Implements Serializable.
886 * @param string $serialized The serialized HTTP header (i.e. "Name: value")
888 function unserialize($serialized) {}
891 * The message class builds the foundation for any request and response message.
893 * See http\Client\Request and http\Client\Response, as well as http\Env\Request and http\Env\Response.
895 class Message
implements \Countable
, \Serializable
, \Iterator
{
897 * No specific type of message.
903 const TYPE_REQUEST
= 1;
905 * A response message.
907 const TYPE_RESPONSE
= 2;
909 * The message type. See http\Message::TYPE_* constants.
914 protected $type = http\Message
::TYPE_NONE
;
916 * The message's body.
919 * @var http\Message\Body
921 protected $body = NULL;
923 * The request method if the message is of type request.
928 protected $requestMethod = "";
930 * The request url if the message is of type request.
935 protected $requestUrl = "";
937 * The respose status phrase if the message is of type response.
942 protected $responseStatus = "";
944 * The response code if the message is of type response.
949 protected $responseCode = 0;
951 * A custom HTTP protocol version.
956 protected $httpVersion = NULL;
958 * Any message headers.
963 protected $headers = NULL;
965 * Any parent message.
970 protected $parentMessage;
972 * Create a new HTTP message.
974 * @param mixed $message Either a resource or a string, representing the HTTP message.
975 * @param bool $greedy Whether to read from a $message resource until EOF.
976 * @throws http\Exception\InvalidArgumentException
977 * @throws http\Exception\BadMessageException
979 function __construct($message = NULL, $greedy = true) {}
981 * Retrieve the message serialized to a string.
982 * Alias of http\Message::toString().
984 * @return string the single serialized HTTP message.
986 function __toString() {}
988 * Append the data of $body to the message's body.
989 * See http\Message::setBody() and http\Message\Body::append().
991 * @param http\Message\Body $body The message body to add.
992 * @return http\Message self.
994 function addBody($body) {}
996 * Add an header, appending to already existing headers.
997 * See http\Message::addHeaders() and http\Message::setHeader().
999 * @param string $name The header name.
1000 * @param mixed $value The header value.
1001 * @return http\Message self.
1003 function addHeader($name, $value) {}
1005 * Add headers, optionally appending values, if header keys already exist.
1006 * See http\Message::addHeader() and http\Message::setHeaders().
1008 * @param array $headers The HTTP headers to add.
1009 * @param bool $append Whether to append values for existing headers.
1010 * @return http\Message self.
1012 function addHeaders($headers, $append = false) {}
1014 * Implements Countable.
1016 * @return int the count of messages in the chain above the current message.
1020 * Implements iterator.
1021 * See http\Message::valid() and http\Message::rewind().
1023 * @return http\Message the current message in the iterated message chain.
1025 function current() {}
1027 * Detach a clone of this message from any message chain.
1029 * @throws http\Exception\InvalidArgumentException
1030 * @return http\Message clone.
1032 function detach() {}
1034 * Retrieve the message's body.
1035 * See http\Message::setBody().
1037 * @throws http\Exception\InvalidArgumentException
1038 * @throws http\Exception\UnexpectedValueEcxeption
1039 * @return http\Message\Body the message body.
1041 function getBody() {}
1043 * Retrieve a single header, optionally hydrated into a http\Header extending class.
1045 * @param string $header The header's name.
1046 * @param string $into_class The name of a class extending http\Header.
1047 * @return mixed|http\Header the header value if $into_class is NULL.
1048 * or http\Header descendant.
1050 function getHeader($header, $into_class = NULL) {}
1052 * Retrieve all message headers.
1053 * See http\Message::setHeaders() and http\Message::getHeader().
1055 * @return array the message's headers.
1057 function getHeaders() {}
1059 * Retreive the HTTP protocol version of the message.
1060 * See http\Message::setHttpVersion().
1062 * @return string the HTTP protocol version, e.g. "1.0"; defaults to "1.1".
1064 function getHttpVersion() {}
1066 * Retrieve the first line of a request or response message.
1067 * See http\Message::setInfo and also:
1069 * * http\Message::getType()
1070 * * http\Message::getHttpVersion()
1071 * * http\Message::getResponseCode()
1072 * * http\Message::getResponseStatus()
1073 * * http\Message::getRequestMethod()
1074 * * http\Message::getRequestUrl()
1076 function getInfo() {}
1078 * Retrieve any parent message.
1079 * See http\Message::reverse().
1081 * @throws http\Exception\InvalidArgumentException
1082 * @throws http\Exception\BadMethodCallException
1083 * @return http /Message, the parent message.
1085 function getParentMessage() {}
1087 * Retrieve the request method of the message.
1088 * See http\Message::setRequestMethod() and http\Message::getRequestUrl().
1090 * @return string|false the request method.
1091 * or false if the message was not of type request.
1093 function getRequestMethod() {}
1095 * Retrieve the request URL of the message.
1096 * See http\Message::setRequestUrl().
1098 * @return string|false the request URL; usually the path and the querystring.
1099 * or false if the message was not of type request.
1101 function getRequestUrl() {}
1103 * Retrieve the response code of the message.
1104 * See http\Message::setResponseCode() and http\Message::getResponseStatus().
1106 * @return int|false the response status code.
1107 * or false if the message is not of type response.
1109 function getResponseCode() {}
1111 * Retrieve the response status of the message.
1112 * See http\Message::setResponseStatus() and http\Message::getResponseCode().
1114 * @return string|false the response status phrase.
1115 * or false if the message is not of type response.
1117 function getResponseStatus() {}
1119 * Retrieve the type of the message.
1120 * See http\Message::setType() and http\Message::getInfo().
1122 * @return int the message type. See http\Message::TYPE_* constants.
1124 function getType() {}
1126 * Check whether this message is a multipart message based on it's content type.
1127 * If the message is a multipart message and a reference $boundary is given, the boundary string of the multipart message will be stored in $boundary.
1129 * See http\Message::splitMultipartBody().
1131 * @return bool whether this is a message with a multipart "Content-Type".
1133 function isMultipart() {}
1135 * Implements Iterator.
1136 * See http\Message::current() and http\Message::rewind().
1138 * @return int a non-sequential integer key.
1142 * Implements Iterator.
1143 * See http\Message::valid() and http\Message::rewind().
1147 * Prepend message(s) $message to this message, or the top most message of this message chain.
1150 * > The message chains must not overlap.
1152 * @param http\Message $message The message (chain) to prepend as parent messages.
1153 * @param bool $top Whether to prepend to the top-most parent message.
1154 * @throws http\Exception\InvalidArgumentException
1155 * @throws http\Exception\UnexpectedValueException
1156 * @return http\Message self.
1158 function prepend($message, $top = true) {}
1160 * Reverse the message chain and return the former top-most message.
1163 * > Message chains are ordered in reverse-parsed order by default, i.e. the last parsed message is the message you'll receive from any call parsing HTTP messages.
1165 * > This call re-orders the messages of the chain and returns the message that was parsed first with any later parsed messages re-parentized.
1167 * @throws http\Exception\InvalidArgumentException
1168 * @return http\Message the other end of the message chain.
1170 function reverse() {}
1172 * Implements Iterator.
1174 function rewind() {}
1176 * Implements Serializable.
1178 * @return string the serialized HTTP message.
1180 function serialize() {}
1182 * Set the message's body.
1183 * See http\Message::getBody() and http\Message::addBody().
1185 * @param http\Message\Body $body The new message body.
1186 * @throws http\Exception\InvalidArgumentException
1187 * @throws http\Exception\UnexpectedValueException
1188 * @return http\Message self.
1190 function setBody($body) {}
1192 * Set a single header.
1193 * See http\Message::getHeader() and http\Message::addHeader().
1196 * > Prior to v2.5.6/v3.1.0 headers with the same name were merged into a single
1197 * > header with values concatenated by comma.
1199 * @param string $header The header's name.
1200 * @param mixed $value The header's value. Removes the header if NULL.
1201 * @return http\Message self.
1203 function setHeader($header, $value = NULL) {}
1205 * Set the message headers.
1206 * See http\Message::getHeaders() and http\Message::addHeaders().
1209 * > Prior to v2.5.6/v3.1.0 headers with the same name were merged into a single
1210 * > header with values concatenated by comma.
1212 * @param array $headers The message's headers.
1213 * @return http\Message null.
1215 function setHeaders($headers = NULL) {}
1217 * Set the HTTP protocol version of the message.
1218 * See http\Message::getHttpVersion().
1220 * @param string $http_version The protocol version, e.g. "1.1", optionally prefixed by "HTTP/".
1221 * @throws http\Exception\InvalidArgumentException
1222 * @throws http\Exception\BadHeaderException
1223 * @return http\Message self.
1225 function setHttpVersion($http_version) {}
1227 * Set the complete message info, i.e. type and response resp. request information, at once.
1228 * See http\Message::getInfo().
1230 * @param string $http_info The message info (first line of an HTTP message).
1231 * @throws http\Exception\InvalidArgumentException
1232 * @throws http\Exception\BadHeaderException
1233 * @return http\Message self.
1235 function setInfo($http_info) {}
1237 * Set the request method of the message.
1238 * See http\Message::getRequestMethod() and http\Message::setRequestUrl().
1240 * @param string $method The request method.
1241 * @throws http\Exception\InvalidArgumentException
1242 * @throws http\Exception\BadMethodCallException
1243 * @return http\Message self.
1245 function setRequestMethod($method) {}
1247 * Set the request URL of the message.
1248 * See http\Message::getRequestUrl() and http\Message::setRequestMethod().
1250 * @param string $url The request URL.
1251 * @throws http\Exception\InvalidArgumentException
1252 * @throws http\Exception\BadMethodCallException
1253 * @return http\Message self.
1255 function setRequestUrl($url) {}
1257 * Set the response status code.
1258 * See http\Message::getResponseCode() and http\Message::setResponseStatus().
1261 * > This method also resets the response status phrase to the default for that code.
1263 * @param int $response_code The response code.
1264 * @param bool $strict Whether to check that the response code is between 100 and 599 inclusive.
1265 * @throws http\Exception\InvalidArgumentException
1266 * @throws http\Exception\BadMethodCallException
1267 * @return http\Message self.
1269 function setResponseCode($response_code, $strict = true) {}
1271 * Set the response status phrase.
1272 * See http\Message::getResponseStatus() and http\Message::setResponseCode().
1274 * @param string $response_status The status phrase.
1275 * @throws http\Exception\InvalidArgumentException
1276 * @throws http\Exception\BadMethodCallException
1277 * @return http\Message self.
1279 function setResponseStatus($response_status) {}
1281 * Set the message type and reset the message info.
1282 * See http\Message::getType() and http\Message::setInfo().
1284 * @param int $type The desired message type. See the http\Message::TYPE_* constants.
1285 * @return http\Message self.
1287 function setType($type) {}
1289 * Splits the body of a multipart message.
1290 * See http\Message::isMultipart() and http\Message\Body::addPart().
1292 * @throws http\Exception\InvalidArgumentException
1293 * @throws http\Exception\BadMethodCallException
1294 * @throws http\Exception\BadMessageException
1295 * @return http\Message a message chain of all messages of the multipart body.
1297 function splitMultipartBody() {}
1299 * Stream the message through a callback.
1301 * @param callable $callback The callback of the form function(http\Message $from, string $data).
1302 * @param int $offset Start to stream from this offset.
1303 * @param int $maxlen Stream at most $maxlen bytes, or all if $maxlen is less than 1.
1304 * @return http\Message self.
1306 function toCallback($callback, $offset = 0, $maxlen = 0) {}
1308 * Stream the message into stream $stream, starting from $offset, streaming $maxlen at most.
1310 * @param resource $stream The resource to write to.
1311 * @param int $offset The starting offset.
1312 * @param int $maxlen The maximum amount of data to stream. All content if less than 1.
1313 * @return http\Message self.
1315 function toStream($stream, $offset = 0, $maxlen = 0) {}
1317 * Retrieve the message serialized to a string.
1319 * @param bool $include_parent Whether to include all parent messages.
1320 * @return string the HTTP message chain serialized to a string.
1322 function toString($include_parent = false) {}
1324 * Implements Serializable.
1326 * @param string $data The serialized message.
1328 function unserialize($data) {}
1330 * Implements Iterator.
1331 * See http\Message::current() and http\Message::rewind().
1333 * @return bool whether http\Message::current() would not return NULL.
1338 * Parse, interpret and compose HTTP (header) parameters.
1340 class Params
implements \ArrayAccess
{
1342 * The default parameter separator (",").
1344 const DEF_PARAM_SEP
= ',';
1346 * The default argument separator (";").
1348 const DEF_ARG_SEP
= ';';
1350 * The default value separator ("=").
1352 const DEF_VAL_SEP
= '=';
1354 * Empty param separator to parse cookies.
1356 const COOKIE_PARAM_SEP
= '';
1358 * Do not interpret the parsed parameters.
1360 const PARSE_RAW
= 0;
1362 * Interpret input as default formatted parameters.
1364 const PARSE_DEFAULT
= 17;
1366 * Urldecode single units of parameters, arguments and values.
1368 const PARSE_URLENCODED
= 4;
1370 * Parse sub dimensions indicated by square brackets.
1372 const PARSE_DIMENSION
= 8;
1374 * Parse URL querystring (same as http\Params::PARSE_URLENCODED|http\Params::PARSE_DIMENSION).
1376 const PARSE_QUERY
= 12;
1378 * Parse [RFC5987](http://tools.ietf.org/html/rfc5987) style encoded character set and language information embedded in HTTP header params.
1380 const PARSE_RFC5987
= 16;
1382 * Parse [RFC5988](http://tools.ietf.org/html/rfc5988) (Web Linking) tags of Link headers.
1384 const PARSE_RFC5988
= 32;
1386 * The (parsed) parameters.
1391 public $params = NULL;
1393 * The parameter separator(s).
1398 public $param_sep = http\Params
::DEF_PARAM_SEP
;
1400 * The argument separator(s).
1405 public $arg_sep = http\Params
::DEF_ARG_SEP
;
1407 * The value separator(s).
1412 public $val_sep = http\Params
::DEF_VAL_SEP
;
1414 * The modus operandi of the parser. See http\Params::PARSE_* constants.
1419 public $flags = http\Params
::PARSE_DEFAULT
;
1421 * Instantiate a new HTTP (header) parameter set.
1423 * @param mixed $params Pre-parsed parameters or a string to be parsed.
1424 * @param mixed $ps The parameter separator(s).
1425 * @param mixed $as The argument separator(s).
1426 * @param mixed $vs The value separator(s).
1427 * @param int $flags The modus operandi. See http\Params::PARSE_* constants.
1428 * @throws http\Exception\InvalidArgumentException
1429 * @throws http\Exception\RuntimeException
1431 function __construct($params = NULL, $ps = NULL, $as = NULL, $vs = NULL, $flags = NULL) {}
1433 * String cast handler. Alias of http\Params::toString().
1434 * Returns a stringified version of the parameters.
1436 * @return string version of the parameters.
1438 function __toString() {}
1440 * Implements ArrayAccess.
1442 * @param string $name The offset to look after.
1443 * @return bool Existence.
1445 function offsetExists($name) {}
1447 * Implements ArrayAccess.
1449 * @param string $name The offset to retrieve.
1450 * @return mixed contents at offset.
1452 function offsetGet($name) {}
1454 * Implements ArrayAccess.
1456 * @param string $name The offset to modify.
1457 * @param mixed $value The value to set.
1459 function offsetSet($name, $value) {}
1461 * Implements ArrayAccess.
1463 * @param string $name The offset to delete.
1465 function offsetUnset($name) {}
1467 * Convenience method that simply returns http\Params::$params.
1469 * @return array of paramters.
1471 function toArray() {}
1473 * Returns a stringified version of the parameters.
1475 * @return string version of the parameters.
1477 function toString() {}
1480 * The http\QueryString class provides versatile facilities to retrieve, use and manipulate query strings and form data.
1482 class QueryString
implements \Serializable
, \ArrayAccess
, \IteratorAggregate
{
1484 * Cast requested value to bool.
1486 const TYPE_BOOL
= 13;
1488 * Cast requested value to int.
1492 * Cast requested value to float.
1494 const TYPE_FLOAT
= 5;
1496 * Cast requested value to string.
1498 const TYPE_STRING
= 6;
1500 * Cast requested value to an array.
1502 const TYPE_ARRAY
= 7;
1504 * Cast requested value to an object.
1506 const TYPE_OBJECT
= 8;
1508 * The global instance. See http\QueryString::getGlobalInstance().
1511 * @var http\QueryString
1513 private $instance = NULL;
1520 private $queryArray = NULL;
1522 * Create an independent querystring instance.
1524 * @param mixed $params The query parameters to use or parse.
1525 * @throws http\Exception\BadQueryStringException
1527 function __construct($params = NULL) {}
1529 * Retrieve an querystring value.
1531 * See http\QueryString::TYPE_* constants.
1533 * @param string $name The key to retrieve the value for.
1534 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
1535 * @param mixed $defval The default value to return if the key $name does not exist.
1536 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
1537 * @return http\QueryString|string|mixed if called without arguments.
1538 * or string the whole querystring if $name is of zero length.
1539 * or mixed $defval if the key $name does not exist.
1540 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
1541 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
1543 function get($name = NULL, $type = NULL, $defval = NULL, $delete = false) {}
1545 * Retrieve an array value with at offset $name.
1547 * @param string $name The key to look up.
1548 * @param mixed $defval The default value to return if the offset $name does not exist.
1549 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1550 * @return array|mixed the (casted) value.
1551 * or mixed $defval if offset $name does not exist.
1553 function getArray($name, $defval = NULL, $delete = false) {}
1555 * Retrieve a boolean value at offset $name.
1557 * @param string $name The key to look up.
1558 * @param mixed $defval The default value to return if the offset $name does not exist.
1559 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1560 * @return bool|mixed the (casted) value.
1561 * or mixed $defval if offset $name does not exist.
1563 function getBool($name, $defval = NULL, $delete = false) {}
1565 * Retrieve a float value at offset $name.
1567 * @param string $name The key to look up.
1568 * @param mixed $defval The default value to return if the offset $name does not exist.
1569 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1570 * @return float|mixed the (casted) value.
1571 * or mixed $defval if offset $name does not exist.
1573 function getFloat($name, $defval = NULL, $delete = false) {}
1575 * Retrieve the global querystring instance referencing $_GET.
1577 * @throws http\Exception\UnexpectedValueException
1578 * @return http\QueryString the http\QueryString::$instance
1580 function getGlobalInstance() {}
1582 * Retrieve a int value at offset $name.
1584 * @param string $name The key to look up.
1585 * @param mixed $defval The default value to return if the offset $name does not exist.
1586 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1587 * @return int|mixed the (casted) value.
1588 * or mixed $defval if offset $name does not exist.
1590 function getInt($name, $defval = NULL, $delete = false) {}
1592 * Implements IteratorAggregate.
1594 * @throws http\Exception\InvalidArgumentException
1595 * @throws InvalidArgumentException
1597 function getIterator() {}
1599 * Retrieve a object value with at offset $name.
1601 * @param string $name The key to look up.
1602 * @param mixed $defval The default value to return if the offset $name does not exist.
1603 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1604 * @return object|mixed the (casted) value.
1605 * or mixed $defval if offset $name does not exist.
1607 function getObject($name, $defval = NULL, $delete = false) {}
1609 * Retrieve a string value with at offset $name.
1611 * @param string $name The key to look up.
1612 * @param mixed $defval The default value to return if the offset $name does not exist.
1613 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1614 * @return string|mixed the (casted) value.
1615 * or mixed $defval if offset $name does not exist.
1617 function getString($name, $defval = NULL, $delete = false) {}
1619 * Set additional $params to a clone of this instance.
1620 * See http\QueryString::set().
1623 * > This method returns a clone (copy) of this instance.
1625 * @param mixed $params Additional params as object, array or string to parse.
1626 * @throws http\Exception\BadQueryStringException
1627 * @return http\QueryString clone.
1629 function mod($params = NULL) {}
1631 * Implements ArrayAccess.
1633 * @param string $name The offset to look up.
1634 * @return bool whether the key $name isset.
1636 function offsetExists($name) {}
1638 * Implements ArrayAccess.
1640 * @param mixed $offset The offset to look up.
1641 * @return mixed|NULL the value locate at offset $name.
1642 * or NULL if key $name could not be found.
1644 function offsetGet($offset) {}
1646 * Implements ArrayAccess.
1648 * @param string $name The key to set the value for.
1649 * @param mixed $data The data to place at offset $name.
1651 function offsetSet($name, $data) {}
1653 * Implements ArrayAccess.
1655 * @param string $name The offset to look up.
1657 function offsetUnset($name) {}
1659 * Implements Serializable.
1660 * See http\QueryString::toString().
1662 * @return string the x-www-form-urlencoded querystring.
1664 function serialize() {}
1666 * Set additional querystring entries.
1668 * @param mixed $params Additional params as object, array or string to parse.
1669 * @return http\QueryString self.
1671 function set($params) {}
1673 * Simply returns http\QueryString::$queryArray.
1675 * @return array the $queryArray property.
1677 function toArray() {}
1679 * Get the string represenation of the querystring (x-www-form-urlencoded).
1681 * @return string the x-www-form-urlencoded querystring.
1683 function toString() {}
1685 * Implements Serializable.
1687 * @param string $serialized The x-www-form-urlencoded querystring.
1688 * @throws http\Exception
1690 function unserialize($serialized) {}
1692 * Translate character encodings of the querystring with ext/iconv.
1695 * > This method is only available when ext/iconv support was enabled at build time.
1697 * @param string $from_enc The encoding to convert from.
1698 * @param string $to_enc The encoding to convert to.
1699 * @throws http\Exception\InvalidArgumentException
1700 * @throws http\Exception\BadConversionException
1701 * @return http\QueryString self.
1703 function xlate($from_enc, $to_enc) {}
1706 * The http\Url class provides versatile means to parse, construct and manipulate URLs.
1710 * Replace parts of the old URL with parts of the new.
1714 * Whether a relative path should be joined into the old path.
1716 const JOIN_PATH
= 1;
1718 * Whether the querystrings should be joined.
1720 const JOIN_QUERY
= 2;
1722 * Strip the user information from the URL.
1724 const STRIP_USER
= 4;
1726 * Strip the password from the URL.
1728 const STRIP_PASS
= 8;
1730 * Strip user and password information from URL (same as STRIP_USER|STRIP_PASS).
1732 const STRIP_AUTH
= 12;
1734 * Do not include the port.
1736 const STRIP_PORT
= 32;
1738 * Do not include the URL path.
1740 const STRIP_PATH
= 64;
1742 * Do not include the URL querystring.
1744 const STRIP_QUERY
= 128;
1746 * Strip the fragment (hash) from the URL.
1748 const STRIP_FRAGMENT
= 256;
1750 * Strip everything except scheme and host information.
1752 const STRIP_ALL
= 492;
1754 * Import initial URL parts from the SAPI environment.
1756 const FROM_ENV
= 4096;
1758 * Whether to sanitize the URL path (consolidate double slashes, directory jumps etc.)
1760 const SANITIZE_PATH
= 8192;
1762 * Parse UTF-8 encododed multibyte sequences.
1764 const PARSE_MBUTF8
= 131072;
1766 * Parse locale encoded multibyte sequences (on systems with wide character support).
1768 const PARSE_MBLOC
= 65536;
1770 * Parse and convert multibyte hostnames according to IDNA (with IDNA support).
1772 const PARSE_TOIDN
= 1048576;
1774 * Explicitly request IDNA2003 implementation if available (libidn, idnkit or ICU).
1776 const PARSE_TOIDN_2003
= 9437184;
1778 * Explicitly request IDNA2008 implementation if available (libidn2, idnkit2 or ICU).
1780 const PARSE_TOIDN_2008
= 5242880;
1782 * Percent encode multibyte sequences in the userinfo, path, query and fragment parts of the URL.
1784 const PARSE_TOPCT
= 2097152;
1786 * Continue parsing when encountering errors.
1788 const IGNORE_ERRORS
= 268435456;
1790 * Suppress errors/exceptions.
1792 const SILENT_ERRORS
= 536870912;
1794 * Standard flags used by default internally for e.g. http\Message::setRequestUrl().
1795 * Enables joining path and query, sanitizing path, multibyte/unicode, international domain names and transient percent encoding.
1797 const STDFLAGS
= 3350531;
1804 public $scheme = NULL;
1806 * Authenticating user.
1811 public $user = NULL;
1813 * Authentication password.
1818 public $pass = NULL;
1825 public $host = NULL;
1832 public $port = NULL;
1839 public $path = NULL;
1846 public $query = NULL;
1848 * URL fragment (hash).
1853 public $fragment = NULL;
1855 * Create an instance of an http\Url.
1858 * > Prior to v3.0.0, the default for the $flags parameter was http\Url::FROM_ENV.
1860 * See also http\Env\Url.
1862 * @param mixed $old_url Initial URL parts. Either an array, object, http\Url instance or string to parse.
1863 * @param mixed $new_url Overriding URL parts. Either an array, object, http\Url instance or string to parse.
1864 * @param int $flags The modus operandi of constructing the url. See http\Url constants.
1865 * @throws http\Exception\InvalidArgumentException
1866 * @throws http\Exception\BadUrlException
1868 function __construct($old_url = NULL, $new_url = NULL, $flags = 0) {}
1870 * String cast handler. Alias of http\Url::toString().
1872 * @return string the URL as string.
1874 function __toString() {}
1876 * Clone this URL and apply $parts to the cloned URL.
1879 * > This method returns a clone (copy) of this instance.
1881 * @param mixed $parts New URL parts.
1882 * @param int $flags Modus operandi of URL construction. See http\Url constants.
1883 * @throws http\Exception\InvalidArgumentException
1884 * @throws http\Exception\BadUrlException
1885 * @return http\Url clone.
1887 function mod($parts, $flags = http\Url
::JOIN_PATH|http\Url
::JOIN_QUERY|http\Url
::SANITIZE_PATH
) {}
1889 * Retrieve the URL parts as array.
1891 * @return array the URL parts.
1893 function toArray() {}
1895 * Get the string prepresentation of the URL.
1897 * @return string the URL as string.
1899 function toString() {}
1902 * The http\Client\Curl namespace holds option value constants specific to the curl driver of the http\Client.
1904 namespace http\Client\Curl
;
1906 * Bitmask of available libcurl features.
1907 * See http\Client\Curl\Features namespace.
1909 const FEATURES
= 4179869;
1911 * List of library versions of or linked into libcurl,
1912 * e.g. "libcurl/7.50.0 OpenSSL/1.0.2h zlib/1.2.8 libidn/1.32 nghttp2/1.12.0".
1913 * See http\Client\Curl\Versions namespace.
1915 const VERSIONS
= 'libcurl/7.52.1 OpenSSL/1.0.2r zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3';
1917 * Use HTTP/1.0 protocol version.
1919 const HTTP_VERSION_1_0
= 1;
1921 * Use HTTP/1.1 protocol version.
1923 const HTTP_VERSION_1_1
= 2;
1925 * Use HTTP/2 protocol version. Available if libcurl is v7.33.0 or more recent and was built with nghttp2 support.
1927 const HTTP_VERSION_2_0
= 3;
1929 * Use any HTTP protocol version.
1931 const HTTP_VERSION_ANY
= 0;
1933 * Use TLS v1.0 encryption.
1935 const SSL_VERSION_TLSv1_0
= 4;
1937 * Use TLS v1.1 encryption.
1939 const SSL_VERSION_TLSv1_1
= 5;
1941 * Use TLS v1.2 encryption.
1943 const SSL_VERSION_TLSv1_2
= 6;
1945 * Use any TLS v1 encryption.
1947 const SSL_VERSION_TLSv1
= 1;
1949 * Use SSL v2 encryption.
1951 const SSL_VERSION_SSLv2
= 2;
1953 * Use SSL v3 encryption.
1955 const SSL_VERSION_SSLv3
= 3;
1957 * Use any encryption.
1959 const SSL_VERSION_ANY
= 0;
1961 * Use TLS SRP authentication. Available if libcurl is v7.21.4 or more recent and was built with gnutls or openssl with TLS-SRP support.
1963 const TLS_AUTH_SRP
= NULL;
1965 * Use IPv4 resolver.
1967 const IPRESOLVE_V4
= 1;
1969 * Use IPv6 resolver.
1971 const IPRESOLVE_V6
= 2;
1975 const IPRESOLVE_ANY
= 0;
1977 * Use Basic authentication.
1979 const AUTH_BASIC
= 1;
1981 * Use Digest authentication.
1983 const AUTH_DIGEST
= 2;
1985 * Use IE (lower v7) quirks with Digest authentication. Available if libcurl is v7.19.3 or more recent.
1987 const AUTH_DIGEST_IE
= 16;
1989 * Use NTLM authentication.
1991 const AUTH_NTLM
= 8;
1993 * Use GSS-Negotiate authentication.
1995 const AUTH_GSSNEG
= 4;
1997 * Use HTTP Netgotiate authentication (SPNEGO, RFC4559). Available if libcurl is v7.38.0 or more recent.
1999 const AUTH_SPNEGO
= 4;
2001 * Use any authentication.
2003 const AUTH_ANY
= -17;
2005 * Use SOCKSv4 proxy protocol.
2007 const PROXY_SOCKS4
= 4;
2009 * Use SOCKSv4a proxy protocol.
2011 const PROXY_SOCKS4A
= 5;
2013 * Use SOCKS5h proxy protocol.
2015 const PROXY_SOCKS5_HOSTNAME
= 5;
2017 * Use SOCKS5 proxy protoccol.
2019 const PROXY_SOCKS5
= 5;
2021 * Use HTTP/1.1 proxy protocol.
2023 const PROXY_HTTP
= 0;
2025 * Use HTTP/1.0 proxy protocol. Available if libcurl is v7.19.4 or more recent.
2027 const PROXY_HTTP_1_0
= 1;
2029 * Keep POSTing on 301 redirects. Available if libcurl is v7.19.1 or more recent.
2031 const POSTREDIR_301
= 1;
2033 * Keep POSTing on 302 redirects. Available if libcurl is v7.19.1 or more recent.
2035 const POSTREDIR_302
= 2;
2037 * Keep POSTing on 303 redirects. Available if libcurl is v7.19.1 or more recent.
2039 const POSTREDIR_303
= 4;
2041 * Keep POSTing on any redirect. Available if libcurl is v7.19.1 or more recent.
2043 const POSTREDIR_ALL
= 7;
2044 namespace http\Client
;
2046 * The http\Client\Request class provides an HTTP message implementation tailored to represent a request message to be sent by the client.
2048 * See http\Client::enqueue().
2050 class Request
extends \http\Message
{
2052 * Array of options for this request, which override client options.
2057 protected $options = NULL;
2059 * Create a new client request message to be enqueued and sent by http\Client.
2061 * @param string $meth The request method.
2062 * @param string $url The request URL.
2063 * @param array $headers HTTP headers.
2064 * @param http\Message\Body $body Request body.
2065 * @throws http\Exception\InvalidArgumentException
2066 * @throws http\Exception\UnexpectedValueException
2068 function __construct($meth = NULL, $url = NULL, $headers = NULL, $body = NULL) {}
2070 * Add querystring data.
2071 * See http\Client\Request::setQuery() and http\Message::setRequestUrl().
2073 * @param mixed $query_data Additional querystring data.
2074 * @throws http\Exception\InvalidArgumentException
2075 * @throws http\Exception\BadQueryStringException
2076 * @return http\Client\Request self.
2078 function addQuery($query_data) {}
2080 * Add specific SSL options.
2081 * See http\Client\Request::setSslOptions(), http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2083 * @param array $ssl_options Add this SSL options.
2084 * @throws http\Client\InvalidArgumentException
2085 * @return http\Client\Request self.
2087 function addSslOptions($ssl_options = NULL) {}
2089 * Extract the currently set "Content-Type" header.
2090 * See http\Client\Request::setContentType().
2092 * @return string|NULL the currently set content type.
2093 * or NULL if no "Content-Type" header is set.
2095 function getContentType() {}
2097 * Get priorly set options.
2098 * See http\Client\Request::setOptions().
2100 * @return array options.
2102 function getOptions() {}
2104 * Retrieve the currently set querystring.
2106 * @return string|NULL the currently set querystring.
2107 * or NULL if no querystring is set.
2109 function getQuery() {}
2111 * Retrieve priorly set SSL options.
2112 * See http\Client\Request::getOptions() and http\Client\Request::setSslOptions().
2114 * @return array SSL options.
2116 function getSslOptions() {}
2118 * Set the MIME content type of the request message.
2120 * @param string $content_type The MIME type used as "Content-Type".
2121 * @throws http\Exception\InvalidArgumentException
2122 * @throws http\Exception\UnexpectedValueException
2123 * @return http\Client\Request self.
2125 function setContentType($content_type) {}
2127 * Set client options.
2128 * See http\Client::setOptions() and http\Client\Curl.
2130 * Request specific options override general options which were set in the client.
2133 * > Only options specified prior enqueueing a request are applied to the request.
2135 * @param array $options The options to set.
2136 * @throws http\Client\InvalidArgumentException
2137 * @return http\Client\Request self.
2139 function setOptions($options = NULL) {}
2141 * (Re)set the querystring.
2142 * See http\Client\Request::addQuery() and http\Message::setRequestUrl().
2144 * @param mixed $query_data
2145 * @throws http\Exception\InvalidArgumentException
2146 * @throws http\Exception\BadQueryStringException
2147 * @return http\Client\Request self.
2149 function setQuery($query_data) {}
2151 * Specifically set SSL options.
2152 * See http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2154 * @param array $ssl_options Set SSL options to this array.
2155 * @throws http\Client\InvalidArgumentException
2156 * @return http\Client\Request self.
2158 function setSslOptions($ssl_options = NULL) {}
2161 * The http\Client\Response class represents an HTTP message the client returns as answer from a server to an http\Client\Request.
2163 class Response
extends \http\Message
{
2165 * Extract response cookies.
2166 * Parses any "Set-Cookie" response headers into an http\Cookie list. See http\Cookie::__construct().
2168 * @param int $flags Cookie parser flags.
2169 * @param array $allowed_extras List of keys treated as extras.
2170 * @return array list of http\Cookie instances.
2172 function getCookies($flags = 0, $allowed_extras = NULL) {}
2174 * Retrieve transfer related information after the request has completed.
2175 * See http\Client::getTransferInfo().
2177 * @param string $name A key to retrieve out of the transfer info.
2178 * @throws http\Exception\InvalidArgumentException
2179 * @throws http\Exception\BadMethodCallException
2180 * @throws http\Exception\UnexpectedValueException
2181 * @return object|mixed stdClass instance with all transfer info if $name was not given.
2182 * or mixed the specific transfer info for $name.
2184 function getTransferInfo($name = NULL) {}
2186 namespace http\Client\Curl
;
2188 * Interface to an user event loop implementation for http\Client::configure()'s $use_eventloop option.
2191 * > This interface was added in v2.6.0, resp. v3.1.0.
2197 const POLL_NONE
= 0;
2199 * Poll for read readiness.
2203 * Poll for write readiness.
2207 * Poll for read/write readiness.
2209 const POLL_INOUT
= 3;
2211 * Stop polling for activity on this descriptor.
2213 const POLL_REMOVE
= 4;
2215 * Initialize the event loop.
2217 * @param callable $run as function(http\Client $c, resource $s = null, int $action = http\Client\Curl\User::POLL_NONE) : int
2218 * Internal callback returning the number of unfinished requests pending.
2222 * > The callback should be run when a timeout occurs or a watched socket needs action.
2224 function init($run);
2226 * Run the loop as long as it does not block.
2229 * > This method is called by http\Client::once(), so it does not need to have an actual implementation if http\Client::once() is never called.
2236 * > This method is called by http\Client::send(), so it does not need to have an actual implementation if http\Client::send() is never called.
2240 * Register (or deregister) a socket watcher.
2242 * @param resource $socket The socket descriptor to watch.
2243 * @param int $poll http\Client\Curl\User::POLL_* constant.
2245 function socket($socket, $poll);
2247 * Register a timeout watcher.
2249 * @param int $timeout_ms Desired maximum timeout in milliseconds.
2251 function timer($timeout_ms);
2253 * Wait/poll/select (block the loop) until events fire.
2256 * > This method is called by http\Client::wait(), so it does not need to have an actual implementation if http\Client::wait() is never called.
2258 * @param int $timeout_ms Block for at most this milliseconds.
2260 function wait($timeout_ms = null);
2263 * CURL feature constants.
2266 * > These constants have been added in v2.6.0, resp. v3.1.0.
2268 namespace http\Client\Curl\Features
;
2270 * Whether libcurl supports asynchronous domain name resolution.
2272 const ASYNCHDNS
= 128;
2274 * Whether libcurl supports the Generic Security Services Application Program Interface. Available if libcurl is v7.38.0 or more recent.
2276 const GSSAPI
= 131072;
2278 * Whether libcurl supports HTTP Generic Security Services negotiation.
2280 const GSSNEGOTIATE
= 32;
2282 * Whether libcurl supports the HTTP/2 protocol. Available if libcurl is v7.33.0 or more recent.
2284 const HTTP2
= 65536;
2286 * Whether libcurl supports international domain names.
2290 * Whether libcurl supports IPv6.
2294 * Whether libcurl supports the old Kerberos protocol.
2296 const KERBEROS4
= 2;
2298 * Whether libcurl supports the more recent Kerberos v5 protocol. Available if libcurl is v7.40.0 or more recent.
2300 const KERBEROS5
= 262144;
2302 * Whether libcurl supports large files.
2304 const LARGEFILE
= 512;
2306 * Whether libcurl supports gzip/deflate compression.
2310 * Whether libcurl supports the NT Lan Manager authentication.
2314 * Whether libcurl supports NTLM delegation to a winbind helper. Available if libcurl is v7.22.0 or more recent.
2316 const NTLM_WB
= 32768;
2318 * Whether libcurl supports the Public Suffix List for cookie host handling. Available if libcurl is v7.47.0 or more recent.
2320 const PSL
= 1048576;
2322 * Whether libcurl supports the Simple and Protected GSSAPI Negotiation Mechanism.
2326 * Whether libcurl supports SSL/TLS protocols.
2330 * Whether libcurl supports the Security Support Provider Interface.
2334 * Whether libcurl supports TLS Secure Remote Password authentication. Available if libcurl is v7.21.4 or more recent.
2336 const TLSAUTH_SRP
= 16384;
2338 * Whether libcurl supports connections to unix sockets. Available if libcurl is v7.40.0 or more recent.
2340 const UNIX_SOCKETS
= 524288;
2342 * CURL version constants.
2345 * > These constants have been added in v2.6.0, resp. v3.1.0.
2347 namespace http\Client\Curl\Versions
;
2349 * Version string of libcurl, e.g. "7.50.0".
2351 const CURL
= '7.52.1';
2353 * Version string of the SSL/TLS library, e.g. "OpenSSL/1.0.2h".
2355 const SSL
= 'OpenSSL/1.0.2r';
2357 * Version string of the zlib compression library, e.g. "1.2.8".
2359 const LIBZ
= '1.2.8';
2361 * Version string of the c-ares library, e.g. "1.11.0".
2365 * Version string of the IDN library, e.g. "1.32".
2368 namespace http\Encoding
;
2370 * Base class for encoding stream implementations.
2372 abstract class Stream
{
2374 * Do no intermittend flushes.
2376 const FLUSH_NONE
= 0;
2378 * Flush at appropriate transfer points.
2380 const FLUSH_SYNC
= 1048576;
2382 * Flush at each IO operation.
2384 const FLUSH_FULL
= 2097152;
2386 * Base constructor for encoding stream implementations.
2388 * @param int $flags See http\Encoding\Stream and implementation specific constants.
2389 * @throws http\Exception\InvalidArgumentException
2390 * @throws http\Exception\RuntimeException
2392 function __construct($flags = 0) {}
2394 * Check whether the encoding stream is already done.
2396 * @return bool whether the encoding stream is completed.
2400 * Finish and reset the encoding stream.
2401 * Returns any pending data.
2403 * @return string any pending data.
2405 function finish() {}
2407 * Flush the encoding stream.
2408 * Returns any pending data.
2410 * @return string any pending data.
2414 * Update the encoding stream with more input.
2416 * @param string $data The data to pass through the stream.
2417 * @return string processed data.
2419 function update($data) {}
2421 namespace http\Encoding\Stream
;
2423 * A stream decoding data encoded with chunked transfer encoding.
2425 class Dechunk
extends \http\Encoding\Stream
{
2427 * Decode chunked encoded data.
2429 * @param string $data The data to decode.
2430 * @param int $decoded_len Out parameter with the length of $data that's been decoded.
2431 * Should be ```strlen($data)``` if not truncated.
2432 * @return string|false the decoded data.
2433 * or string the unencoded data.
2434 * or string the truncated decoded data.
2435 * or false if $data cannot be decoded.
2437 function decode($data, $decoded_len = 0) {}
2440 * A deflate stream supporting deflate, zlib and gzip encodings.
2442 class Deflate
extends \http\Encoding\Stream
{
2444 * Gzip encoding. RFC1952
2446 const TYPE_GZIP
= 16;
2448 * Zlib encoding. RFC1950
2450 const TYPE_ZLIB
= 0;
2452 * Deflate encoding. RFC1951
2454 const TYPE_RAW
= 32;
2456 * Default compression level.
2458 const LEVEL_DEF
= 0;
2460 * Least compression level.
2462 const LEVEL_MIN
= 1;
2464 * Greatest compression level.
2466 const LEVEL_MAX
= 9;
2468 * Default compression strategy.
2470 const STRATEGY_DEF
= 0;
2472 * Filtered compression strategy.
2474 const STRATEGY_FILT
= 256;
2476 * Huffman strategy only.
2478 const STRATEGY_HUFF
= 512;
2480 * Run-length encoding strategy.
2482 const STRATEGY_RLE
= 768;
2484 * Encoding with fixed Huffman codes only.
2486 * > **A note on the compression strategy:**
2488 * > The strategy parameter is used to tune the compression algorithm.
2490 * > Use the value DEFAULT_STRATEGY for normal data, FILTERED for data produced by a filter (or predictor), HUFFMAN_ONLY to force Huffman encoding only (no string match), or RLE to limit match distances to one (run-length encoding).
2492 * > Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between DEFAULT_STRATEGY and HUFFMAN_ONLY.
2494 * > RLE is designed to be almost as fast as HUFFMAN_ONLY, but give better compression for PNG image data.
2496 * > FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
2498 * > The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately.
2500 * >_Source: [zlib Manual](http://www.zlib.net/manual.html)_
2502 const STRATEGY_FIXED
= 1024;
2504 * Encode data with deflate/zlib/gzip encoding.
2506 * @param string $data The data to compress.
2507 * @param int $flags Any compression tuning flags. See http\Encoding\Stream\Deflate and http\Encoding\Stream constants.
2508 * @return string the compressed data.
2510 function encode($data, $flags = 0) {}
2513 * A inflate stream supporting deflate, zlib and gzip encodings.
2515 class Inflate
extends \http\Encoding\Stream
{
2517 * Decode deflate/zlib/gzip encoded data.
2519 * @param string $data The data to uncompress.
2520 * @return string the uncompressed data.
2522 function decode($data) {}
2526 * The http\Env\Request class' instances represent the server's current HTTP request.
2528 * See http\Message for inherited members.
2530 class Request
extends \http\Message
{
2532 * The request's query parameters. ($_GET)
2535 * @var http\QueryString
2537 protected $query = NULL;
2539 * The request's form parameters. ($_POST)
2542 * @var http\QueryString
2544 protected $form = NULL;
2546 * The request's form uploads. ($_FILES)
2551 protected $files = NULL;
2553 * The request's cookies. ($_COOKIE)
2558 protected $cookie = NULL;
2560 * Create an instance of the server's current HTTP request.
2562 * Upon construction, the http\Env\Request acquires http\QueryString instances of query paramters ($\_GET) and form parameters ($\_POST).
2564 * It also compiles an array of uploaded files ($\_FILES) more comprehensive than the original $\_FILES array, see http\Env\Request::getFiles() for that matter.
2566 * @throws http\Exception\InvalidArgumentException
2567 * @throws http\Exception\UnexpectedValueException
2569 function __construct() {}
2571 * Retrieve an URL query value ($_GET).
2573 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2575 * @param string $name The key to retrieve the value for.
2576 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2577 * @param mixed $defval The default value to return if the key $name does not exist.
2578 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2579 * @return http\QueryString|string|mixed if called without arguments.
2580 * or string the whole querystring if $name is of zero length.
2581 * or mixed $defval if the key $name does not exist.
2582 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2583 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2585 function getCookie($name = NULL, $type = NULL, $defval = NULL, $delete = false) {}
2587 * Retrieve the uploaded files list ($_FILES).
2589 * @return array the consolidated upload files array.
2591 function getFiles() {}
2593 * Retrieve a form value ($_POST).
2595 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2597 * @param string $name The key to retrieve the value for.
2598 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2599 * @param mixed $defval The default value to return if the key $name does not exist.
2600 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2601 * @return http\QueryString|string|mixed if called without arguments.
2602 * or string the whole querystring if $name is of zero length.
2603 * or mixed $defval if the key $name does not exist.
2604 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2605 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2607 function getForm($name = NULL, $type = NULL, $defval = NULL, $delete = false) {}
2609 * Retrieve an URL query value ($_GET).
2611 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2613 * @param string $name The key to retrieve the value for.
2614 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2615 * @param mixed $defval The default value to return if the key $name does not exist.
2616 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2617 * @return http\QueryString|string|mixed if called without arguments.
2618 * or string the whole querystring if $name is of zero length.
2619 * or mixed $defval if the key $name does not exist.
2620 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2621 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2623 function getQuery($name = NULL, $type = NULL, $defval = NULL, $delete = false) {}
2626 * The http\Env\Response class' instances represent the server's current HTTP response.
2628 * See http\Message for inherited members.
2630 class Response
extends \http\Message
{
2632 * Do not use content encoding.
2634 const CONTENT_ENCODING_NONE
= 0;
2636 * Support "Accept-Encoding" requests with gzip and deflate encoding.
2638 const CONTENT_ENCODING_GZIP
= 1;
2640 * No caching info available.
2644 * The cache was hit.
2646 const CACHE_HIT
= 1;
2648 * The cache was missed.
2650 const CACHE_MISS
= 2;
2652 * A request instance which overrides the environments default request.
2655 * @var http\Env\Request
2657 protected $request = NULL;
2659 * The response's MIME content type.
2664 protected $contentType = NULL;
2666 * The response's MIME content disposition.
2671 protected $contentDisposition = NULL;
2673 * See http\Env\Response::CONTENT_ENCODING_* constants.
2678 protected $contentEncoding = NULL;
2680 * How the client should treat this response in regards to caching.
2685 protected $cacheControl = NULL;
2692 protected $etag = NULL;
2694 * A "Last-Modified" time stamp.
2699 protected $lastModified = NULL;
2701 * Any throttling delay.
2706 protected $throttleDelay = NULL;
2708 * The chunk to send every $throttleDelay seconds.
2713 protected $throttleChunk = NULL;
2715 * The response's cookies.
2720 protected $cookies = NULL;
2722 * Create a new env response message instance.
2724 * @throws http\Exception\InvalidArgumentException
2725 * @throws http\Exception\UnexpectedValueException
2727 function __construct() {}
2729 * Output buffer handler.
2730 * Appends output data to the body.
2732 * @param string $data The data output.
2733 * @param int $ob_flags Output buffering flags passed from the output buffering control layer.
2734 * @return bool success.
2736 function __invoke($data, $ob_flags = 0) {}
2738 * Manually test the header $header_name of the environment's request for a cache hit.
2739 * http\Env\Response::send() checks that itself, though.
2741 * @param string $header_name The request header to test.
2742 * @return int a http\Env\Response::CACHE_* constant.
2744 function isCachedByEtag($header_name = "If-None-Match") {}
2746 * Manually test the header $header_name of the environment's request for a cache hit.
2747 * http\Env\Response::send() checks that itself, though.
2749 * @param string $header_name The request header to test.
2750 * @return int a http\Env\Response::CACHE_* constant.
2752 function isCachedByLastModified($header_name = "If-Modified-Since") {}
2754 * Send the response through the SAPI or $stream.
2755 * Flushes all output buffers.
2757 * @param resource $stream A writable stream to send the response through.
2758 * @return bool success.
2760 function send($stream = NULL) {}
2762 * Make suggestions to the client how it should cache the response.
2764 * @param string $cache_control (A) "Cache-Control" header value(s).
2765 * @throws http\Exception\InvalidArgumentException
2766 * @return http\Env\Response self.
2768 function setCacheControl($cache_control) {}
2770 * Set the reponse's content disposition parameters.
2772 * @param array $disposition_params MIME content disposition as http\Params array.
2773 * @throws http\Exception\InvalidArgumentException
2774 * @return http\Env\Response self.
2776 function setContentDisposition($disposition_params) {}
2778 * Enable support for "Accept-Encoding" requests with deflate or gzip.
2779 * The response will be compressed if the client indicates support and wishes that.
2781 * @param int $content_encoding See http\Env\Response::CONTENT_ENCODING_* constants.
2782 * @throws http\Exception\InvalidArgumentException
2783 * @return http\Env\Response self.
2785 function setContentEncoding($content_encoding) {}
2787 * Set the MIME content type of the response.
2789 * @param string $conten_type The response's content type.
2790 * @throws http\Env\InvalidArgumentException
2791 * @return http\Env\Response self.
2793 function setContentType($conten_type) {}
2795 * Add cookies to the response to send.
2797 * @param mixed $cookie The cookie to send.
2798 * @throws http\Exception\InvalidArgumentException
2799 * @throws http\Exception\UnexpectedValueException
2800 * @return http\Env\Response self.
2802 function setCookie($cookie) {}
2804 * Override the environment's request.
2806 * @param http\Message $env_request The overriding request message.
2807 * @throws http\Exception\InvalidArgumentException
2808 * @return http\Env\Response self.
2810 function setEnvRequest($env_request) {}
2812 * Set a custom ETag.
2815 * > This will be used for caching and pre-condition checks.
2817 * @param string $etag A ETag.
2818 * @throws http\Exception\InvalidArgumentException
2819 * @return http\Env\Response self.
2821 function setEtag($etag) {}
2823 * Set a custom last modified time stamp.
2826 * > This will be used for caching and pre-condition checks.
2828 * @param int $last_modified A unix timestamp.
2829 * @throws http\Exception\InvalidArgumentException
2830 * @return http\Env\Response self.
2832 function setLastModified($last_modified) {}
2834 * Enable throttling.
2835 * Send $chunk_size bytes every $delay seconds.
2838 * > If you need throttling by regular means, check for other options in your stack, because this method blocks the executing process/thread until the response has completely been sent.
2840 * @param int $chunk_size Bytes to send.
2841 * @param float $delay Seconds to sleep.
2842 * @return http\Env\Response self.
2844 function setThrottleRate($chunk_size, $delay = 1) {}
2847 * URL class using the HTTP environment by default.
2850 * > This class has been added in v3.0.0.
2852 * Always adds http\Url::FROM_ENV to the $flags constructor argument. See also http\Url.
2854 class Url
extends \http\Url
{
2856 namespace http\Exception
;
2858 * A bad conversion (e.g. character conversion) was encountered.
2860 class BadConversionException
extends \DomainException
implements \http\Exception
{
2863 * A bad HTTP header was encountered.
2865 class BadHeaderException
extends \DomainException
implements \http\Exception
{
2868 * A bad HTTP message was encountered.
2870 class BadMessageException
extends \DomainException
implements \http\Exception
{
2873 * A method was called on an object, which was in an invalid or unexpected state.
2875 class BadMethodCallException
extends \BadMethodCallException
implements \http\Exception
{
2878 * A bad querystring was encountered.
2880 class BadQueryStringException
extends \DomainException
implements \http\Exception
{
2883 * A bad HTTP URL was encountered.
2885 class BadUrlException
extends \DomainException
implements \http\Exception
{
2888 * One or more invalid arguments were passed to a method.
2890 class InvalidArgumentException
extends \InvalidArgumentException
implements \http\Exception
{
2893 * A generic runtime exception.
2895 class RuntimeException
extends \RuntimeException
implements \http\Exception
{
2898 * An unexpected value was encountered.
2900 class UnexpectedValueException
extends \UnexpectedValueException
implements \http\Exception
{
2902 namespace http\Header
;
2904 * The parser which is underlying http\Header and http\Message.
2907 * > This class has been added in v2.3.0.
2911 * Finish up parser at end of (incomplete) input.
2917 const STATE_FAILURE
= -1;
2919 * Expecting HTTP info (request/response line) or headers.
2921 const STATE_START
= 0;
2923 * Expecting a key or already parsing a key.
2925 const STATE_KEY
= 1;
2927 * Expecting a value or already parsing the value.
2929 const STATE_VALUE
= 2;
2931 * At EOL of an header, checking whether a folded header line follows.
2933 const STATE_VALUE_EX
= 3;
2935 * A header was completed.
2937 const STATE_HEADER_DONE
= 4;
2939 * Finished parsing the headers.
2942 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
2944 const STATE_DONE
= 5;
2946 * Retrieve the current state of the parser.
2947 * See http\Header\Parser::STATE_* constants.
2949 * @throws http\Exception\InvalidArgumentException
2950 * @return int http\Header\Parser::STATE_* constant.
2952 function getState() {}
2956 * @param string $data The (part of the) header to parse.
2957 * @param int $flags Any combination of [parser flags](http/Header/Parser#Parser.flags:).
2958 * @throws http\Exception\InvalidArgumentException
2959 * @return int http\Header\Parser::STATE_* constant.
2961 function parse($data, $flags) {}
2965 * @param stream $resource The header stream to parse from.
2966 * @param int $flags Any combination of [parser flags](http/Header/Parser#Parser.flags:).
2967 * @throws http\Exception\InvalidArgumentException
2968 * @throws http\Exception\UnexpectedValueException
2969 * @return int http\Header\Parser::STATE_* constant.
2971 function stream($resource, $flags) {}
2973 namespace http\Message
;
2975 * The message body, represented as a PHP (temporary) stream.
2978 * > Currently, http\Message\Body::addForm() creates multipart/form-data bodies.
2980 class Body
implements \Serializable
{
2982 * Create a new message body, optionally referencing $stream.
2984 * @param resource $stream A stream to be used as message body.
2985 * @throws http\Exception\InvalidArgumentException
2986 * @throws http\Exception\UnexpectedValueException
2988 function __construct($stream = NULL) {}
2990 * String cast handler.
2992 * @return string the message body.
2994 function __toString() {}
2996 * Add form fields and files to the message body.
2999 * > Currently, http\Message\Body::addForm() creates "multipart/form-data" bodies.
3001 * @param array $fields List of form fields to add.
3002 * @param array $files List of form files to add.
3004 * $fields must look like:
3007 * "field_name" => "value",
3008 * "multi_field" => [
3014 * $files must look like:
3018 * "name" => "field_name",
3019 * "type" => "content/type",
3020 * "file" => "/path/to/file.ext"
3022 * "name" => "field_name2",
3023 * "type" => "text/plain",
3024 * "file" => "file.ext",
3025 * "data" => "string"
3027 * "name" => "field_name3",
3028 * "type" => "image/jpeg",
3029 * "file" => "file.ext",
3030 * "data" => fopen("/home/mike/Pictures/mike.jpg","r")
3033 * As you can see, a file structure must contain a "file" entry, which holds a file path, and an optional "data" entry, which may either contain a resource to read from or the actual data as string.
3034 * @throws http\Exception\InvalidArgumentException
3035 * @throws http\Exception\RuntimeException
3036 * @return http\Message\Body self.
3038 function addForm($fields = NULL, $files = NULL) {}
3040 * Add a part to a multipart body.
3042 * @param http\Message $part The message part.
3043 * @throws http\Exception\InvalidArgumentException
3044 * @throws http\Exception\RuntimeException
3045 * @return http\Message\Body self.
3047 function addPart($part) {}
3049 * Append plain bytes to the message body.
3051 * @param string $data The data to append to the body.
3052 * @throws http\Exception\InvalidArgumentException
3053 * @throws http\Exception\RuntimeException
3054 * @return http\Message\Body self.
3056 function append($data) {}
3058 * Retrieve the ETag of the body.
3060 * @return string|false an Apache style ETag of inode, mtime and size in hex concatenated by hyphens if the message body stream is stat-able.
3061 * or string a content hash (which algorithm is determined by INI http.etag.mode) if the stream is not stat-able.
3062 * or false if http.etag.mode is not a known hash algorithm.
3066 * Retrieve any boundary of the message body.
3067 * See http\Message::splitMultipartBody().
3069 * @return string|NULL the message body boundary.
3070 * or NULL if this message body has no boundary.
3072 function getBoundary() {}
3074 * Retrieve the underlying stream resource.
3076 * @return resource the underlying stream.
3078 function getResource() {}
3080 * Implements Serializable.
3081 * Alias of http\Message\Body::__toString().
3083 * @return string serialized message body.
3085 function serialize() {}
3087 * Stat size, atime, mtime and/or ctime.
3089 * @param string $field A single stat field to retrieve.
3090 * @return int|object the requested stat field.
3091 * or object stdClass instance holding all four stat fields.
3093 function stat($field = NULL) {}
3095 * Stream the message body through a callback.
3097 * @param callable $callback The callback of the form function(http\Message\Body $from, string $data).
3098 * @param int $offset Start to stream from this offset.
3099 * @param int $maxlen Stream at most $maxlen bytes, or all if $maxlen is less than 1.
3100 * @return http\Message\Body self.
3102 function toCallback($callback, $offset = 0, $maxlen = 0) {}
3104 * Stream the message body into antother stream $stream, starting from $offset, streaming $maxlen at most.
3106 * @param resource $stream The resource to write to.
3107 * @param int $offset The starting offset.
3108 * @param int $maxlen The maximum amount of data to stream. All content if less than 1.
3109 * @return http\Message\Body self.
3111 function toStream($stream, $offset = 0, $maxlen = 0) {}
3113 * Retrieve the message body serialized to a string.
3114 * Alias of http\Message\Body::__toString().
3116 * @return string message body.
3118 function toString() {}
3120 * Implements Serializable.
3122 * @param string $serialized The serialized message body.
3124 function unserialize($serialized) {}
3127 * The parser which is underlying http\Message.
3130 * > This class was added in v2.2.0.
3134 * Finish up parser at end of (incomplete) input.
3138 * Soak up the rest of input if no entity length is deducible.
3140 const DUMB_BODIES
= 2;
3142 * Redirect messages do not contain any body despite of indication of such.
3144 const EMPTY_REDIRECTS
= 4;
3146 * Continue parsing while input is available.
3152 const STATE_FAILURE
= -1;
3154 * Expecting HTTP info (request/response line) or headers.
3156 const STATE_START
= 0;
3160 const STATE_HEADER
= 1;
3162 * Completed parsing headers.
3164 const STATE_HEADER_DONE
= 2;
3168 const STATE_BODY
= 3;
3170 * Soaking up all input as body.
3172 const STATE_BODY_DUMB
= 4;
3174 * Reading body as indicated by `Content-Lenght` or `Content-Range`.
3176 const STATE_BODY_LENGTH
= 5;
3178 * Parsing `chunked` encoded body.
3180 const STATE_BODY_CHUNKED
= 6;
3182 * Finished parsing the body.
3184 const STATE_BODY_DONE
= 7;
3186 * Finished parsing the message.
3189 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
3191 const STATE_DONE
= 9;
3193 * Retrieve the current state of the parser.
3194 * See http\Message\Parser::STATE_* constants.
3196 * @throws http\Exception\InvalidArgumentException
3197 * @return int http\Message\Parser::STATE_* constant.
3199 function getState() {}
3203 * @param string $data The (part of the) message to parse.
3204 * @param int $flags Any combination of [parser flags](http/Message/Parser#Parser.flags:).
3205 * @throws http\Exception\InvalidArgumentException
3206 * @return int http\Message\Parser::STATE_* constant.
3208 function parse($data, $flags) {}
3212 * @param stream $resource The message stream to parse from.
3213 * @param int $flags Any combination of [parser flags](http/Message/Parser#Parser.flags:).
3214 * @throws http\Exception\InvalidArgumentException
3215 * @throws http\Exception\UnexpectedValueException
3216 * @return int http\Message\Parser::STATE_* constant.
3218 function stream($resource, $flags) {}