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(string $driver = NULL, string $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(array $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\Exception\InvalidArgumentException
96 * @return \http\Client self.
98 function addSslOptions(array $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(\SplObserver
$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(array $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(\http\Client\Request
$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(\SplObserver
$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(bool $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(bool $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 retrieved 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 as function(\http\Response $response) : ?bool
194 * A callback to automatically call when the request has finished.
195 * @throws \http\Exception\InvalidArgumentException
196 * @throws \http\Exception\BadMethodCallException
197 * @throws \http\Exception\RuntimeException
198 * @return \http\Client self.
200 function enqueue(\http\Client\Request
$request, callable
$cb = NULL) {}
202 * Get a list of available configuration options and their default values.
204 * See f.e. the [configuration options for the Curl driver](http/Client/Curl#Configuration:).
206 * @throws \http\Exception\InvalidArgumentException
207 * @return array list of key/value pairs of available configuration options and their default values.
209 function getAvailableConfiguration() {}
211 * List available drivers.
213 * @return array list of supported drivers.
215 function getAvailableDrivers() {}
217 * Retrieve a list of available request options and their default values.
219 * See f.e. the [request options for the Curl driver](http/Client/Curl#Options:).
221 * @throws \http\Exception\InvalidArgumentException
222 * @return array list of key/value pairs of available request options and their default values.
224 function getAvailableOptions() {}
226 * Get priorly set custom cookies.
227 * See http\Client::setCookies().
229 * @return array custom cookies.
231 function getCookies() {}
233 * Simply returns the http\Message chain representing the request/response history.
236 * > The history is only recorded while http\Client::$recordHistory is true.
238 * @throws \http\Exception\InvalidArgumentException
239 * @return \http\Message the request/response message chain representing the client's history.
241 function getHistory() {}
243 * Returns the SplObjectStorage holding attached observers.
245 * @throws \http\Exception\InvalidArgumentException
246 * @throws \http\Exception\UnexpectedValueException
247 * @return \SplObjectStorage observer storage.
249 function getObservers() {}
251 * Get priorly set options.
252 * See http\Client::setOptions().
254 * @return array options.
256 function getOptions() {}
258 * Retrieve the progress information for $request.
260 * @param \http\Client\Request $request The request to retrieve the current progress information for.
261 * @throws \http\Exception\InvalidArgumentException
262 * @throws \http\Exception\UnexpectedValueException
263 * @return object|NULL object stdClass instance holding progress information.
264 * or NULL if $request is not enqueued.
266 function getProgressInfo(\http\Client\Request
$request) {}
268 * Retrieve the corresponding response of an already finished request, or the last received response if $request is not set.
271 * > If $request is NULL, then the response is removed from the internal storage (stack-like operation).
273 * @param \http\Client\Request $request The request to fetch the stored response for.
274 * @throws \http\Exception\InvalidArgumentException
275 * @throws \http\Exception\UnexpectedValueException
276 * @return \http\Client\Response|NULL \http\Client\Response the stored response for the request, or the last that was received.
277 * or NULL if no more response was available to pop, when no $request was given.
279 function getResponse(\http\Client\Request
$request = NULL) {}
281 * Retrieve priorly set SSL options.
282 * See http\Client::getOptions() and http\Client::setSslOptions().
284 * @return array SSL options.
286 function getSslOptions() {}
288 * Get transfer related information for a running or finished request.
290 * @param \http\Client\Request $request The request to probe for transfer info.
291 * @throws \http\Exception\InvalidArgumentException
292 * @throws \http\Exception\UnexpectedValueException
293 * @return object stdClass instance holding transfer related information.
295 function getTransferInfo(\http\Client\Request
$request) {}
297 * Implements SplSubject. Notify attached observers about progress with $request.
299 * @param \http\Client\Request $request The request to notify about.
300 * @param object $progress stdClass instance holding progress information.
301 * @throws \http\Exception\InvalidArgumentException
302 * @throws \http\Exception\UnexpectedValueException
303 * @return \http\Client self.
305 function notify(\http\Client\Request
$request = NULL, $progress = NULL) {}
307 * Perform outstanding transfer actions.
308 * See http\Client::wait() for the completing interface.
310 * @return bool true if there are more transfers to complete.
314 * Requeue an http\Client\Request.
316 * 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.
318 * @param \http\Client\Request $request The request to queue.
319 * @param callable $cb as function(\http\Response $response) : ?bool
320 * A callback to automatically call when the request has finished.
321 * @throws \http\Exception\InvalidArgumentException
322 * @throws \http\Exception\RuntimeException
323 * @return \http\Client self.
325 function requeue(\http\Client\Request
$request, callable
$cb = NULL) {}
327 * Reset the client to the initial state.
329 * @return \http\Client self.
333 * Send all enqueued requests.
334 * See http\Client::once() and http\Client::wait() for a more fine grained interface.
336 * @throws \http\Exception\InvalidArgumentException
337 * @throws \http\Exception\RuntimeException
338 * @return \http\Client self.
342 * Set custom cookies.
343 * See http\Client::addCookies() and http\Client::getCookies().
345 * @param array $cookies Set the custom cookies to this array.
346 * @throws \http\Exception\InvalidArgumentException
347 * @return \http\Client self.
349 function setCookies(array $cookies = NULL) {}
351 * Set client debugging callback.
354 * > This method has been added in v2.6.0, resp. v3.1.0.
356 * @param callable $callback as function(http\Client $c, http\Client\Request $r, int $type, string $data)
357 * The debug callback. For $type see http\Client::DEBUG_* constants.
358 * @throws \http\Exception\InvalidArgumentException
359 * @return \http\Client self.
361 function setDebug(callable
$callback) {}
363 * Set client options.
364 * See http\Client\Curl.
367 * > Only options specified prior enqueueing a request are applied to the request.
369 * @param array $options The options to set.
370 * @throws \http\Exception\InvalidArgumentException
371 * @return \http\Client self.
373 function setOptions(array $options = NULL) {}
375 * Specifically set SSL options.
376 * See http\Client::setOptions() and http\Client\Curl\$ssl options.
378 * @param array $ssl_options Set SSL options to this array.
379 * @throws \http\Exception\InvalidArgumentException
380 * @return \http\Client self.
382 function setSslOptions(array $ssl_options = NULL) {}
384 * Wait for $timeout seconds for transfers to provide data.
385 * This is the completion call to http\Client::once().
387 * @param float $timeout Seconds to wait for data on open sockets.
388 * @return bool success.
390 function wait(float $timeout = 0) {}
393 * A class representing a list of cookies with specific attributes.
397 * Do not decode cookie contents.
401 * The cookies' flags have the secure attribute set.
405 * The cookies' flags have the httpOnly attribute set.
409 * Create a new cookie list.
411 * @param mixed $cookies The string or list of cookies to parse or set.
412 * @param int $flags Parse flags. See http\Cookie::PARSE_* constants.
413 * @param array $allowed_extras List of extra attribute names to recognize.
414 * @throws \http\Exception\InvalidArgumentException
415 * @throws \http\Exception\RuntimeException
417 function __construct($cookies = NULL, int $flags = 0, array $allowed_extras = NULL) {}
419 * String cast handler. Alias of http\Cookie::toString().
421 * @return string the cookie(s) represented as string.
423 function __toString() {}
426 * See http\Cookie::setCookie() and http\Cookie::addCookies().
428 * @param string $cookie_name The key of the cookie.
429 * @param string $cookie_value The value of the cookie.
430 * @throws \http\Exception\InvalidArgumentException
431 * @return \http\Cookie self.
433 function addCookie(string $cookie_name, string $cookie_value) {}
435 * (Re)set the cookies.
436 * See http\Cookie::setCookies().
438 * @param array $cookies Add cookies of this array of form ["name" => "value"].
439 * @throws \http\Exception\InvalidArgumentException
440 * @return \http\Cookie self.
442 function addCookies(array $cookies) {}
444 * Add an extra attribute to the cookie list.
445 * See http\Cookie::setExtra().
447 * @param string $extra_name The key of the extra attribute.
448 * @param string $extra_value The value of the extra attribute.
449 * @throws \http\Exception\InvalidArgumentException
450 * @return \http\Cookie self.
452 function addExtra(string $extra_name, string $extra_value) {}
454 * Add several extra attributes.
455 * See http\Cookie::addExtra().
457 * @param array $extras A list of extra attributes of the form ["key" => "value"].
458 * @throws \http\Exception\InvalidArgumentException
459 * @return \http\Cookie self.
461 function addExtras(array $extras) {}
463 * Retrieve a specific cookie value.
464 * See http\Cookie::setCookie().
466 * @param string $cookie_name The key of the cookie to look up.
467 * @return string|NULL string the cookie value.
468 * or NULL if $cookie_name could not be found.
470 function getCookie(string $cookie_name) {}
472 * Get the list of cookies.
473 * See http\Cookie::setCookies().
475 * @return array the list of cookies of form ["name" => "value"].
477 function getCookies() {}
479 * Retrieve the effective domain of the cookie list.
480 * See http\Cookie::setDomain().
482 * @return string the effective domain.
484 function getDomain() {}
486 * Get the currently set expires attribute.
487 * See http\Cookie::setExpires().
490 * > A return value of -1 means that the attribute is not set.
492 * @return int the currently set expires attribute as seconds since the epoch.
494 function getExpires() {}
496 * Retrieve an extra attribute.
497 * See http\Cookie::setExtra().
499 * @param string $name The key of the extra attribute.
500 * @return string the value of the extra attribute.
502 function getExtra(string $name) {}
504 * Retrieve the list of extra attributes.
505 * See http\Cookie::setExtras().
507 * @return array the list of extra attributes of the form ["key" => "value"].
509 function getExtras() {}
511 * Get the currently set flags.
512 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
514 * @return int the currently set flags bitmask.
516 function getFlags() {}
518 * Get the currently set max-age attribute of the cookie list.
519 * See http\Cookie::setMaxAge().
522 * > A return value of -1 means that the attribute is not set.
524 * @return int the currently set max-age.
526 function getMaxAge() {}
528 * Retrieve the path the cookie(s) of this cookie list are effective at.
529 * See http\Cookie::setPath().
531 * @return string the effective path.
533 function getPath() {}
536 * See http\Cookie::addCookie() and http\Cookie::setCookies().
539 * > The cookie will be deleted from the list if $cookie_value is NULL.
541 * @param string $cookie_name The key of the cookie.
542 * @param string $cookie_value The value of the cookie.
543 * @throws \http\Exception\InvalidArgumentException
544 * @return \http\Cookie self.
546 function setCookie(string $cookie_name, string $cookie_value) {}
548 * (Re)set the cookies.
549 * See http\Cookie::addCookies().
551 * @param array $cookies Set the cookies to this array.
552 * @throws \http\Exception\InvalidArgumentException
553 * @return \http\Cookie self.
555 function setCookies(array $cookies = NULL) {}
557 * Set the effective domain of the cookie list.
558 * See http\Cookie::setPath().
560 * @param string $value The domain the cookie(s) belong to.
561 * @throws \http\Exception\InvalidArgumentException
562 * @return \http\Cookie self.
564 function setDomain(string $value = NULL) {}
566 * Set the traditional expires timestamp.
567 * See http\Cookie::setMaxAge() for a safer alternative.
569 * @param int $value The expires timestamp as seconds since the epoch.
570 * @throws \http\Exception\InvalidArgumentException
571 * @return \http\Cookie self.
573 function setExpires(int $value = -1) {}
575 * (Re)set an extra attribute.
576 * See http\Cookie::addExtra().
579 * > The attribute will be removed from the extras list if $extra_value is NULL.
581 * @param string $extra_name The key of the extra attribute.
582 * @param string $extra_value The value of the extra attribute.
583 * @throws \http\Exception\InvalidArgumentException
584 * @return \http\Cookie self.
586 function setExtra(string $extra_name, string $extra_value = NULL) {}
588 * (Re)set the extra attributes.
589 * See http\Cookie::addExtras().
591 * @param array $extras Set the extra attributes to this array.
592 * @throws \http\Exception\InvalidArgumentException
593 * @return \http\Cookie self.
595 function setExtras(array $extras = NULL) {}
597 * Set the flags to specified $value.
598 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
600 * @param int $value The new flags bitmask.
601 * @throws \http\Exception\InvalidArgumentException
602 * @return \http\Cookie self.
604 function setFlags(int $value = 0) {}
606 * Set the maximum age the cookie may have on the client side.
607 * This is a client clock departure safe alternative to the "expires" attribute.
608 * See http\Cookie::setExpires().
610 * @param int $value The max-age in seconds.
611 * @throws \http\Exception\InvalidArgumentException
612 * @return \http\Cookie self.
614 function setMaxAge(int $value = -1) {}
616 * Set the path the cookie(s) of this cookie list should be effective at.
617 * See http\Cookie::setDomain().
619 * @param string $path The URL path the cookie(s) should take effect within.
620 * @throws \http\Exception\InvalidArgumentException
621 * @return \http\Cookie self.
623 function setPath(string $path = NULL) {}
625 * Get the cookie list as array.
627 * @return array the cookie list as array.
629 function toArray() {}
631 * Retrieve the string representation of the cookie list.
632 * See http\Cookie::toArray().
634 * @return string the cookie list as string.
636 function toString() {}
641 namespace http\Encoding
;
644 * The http\Env class provides static methods to manipulate and inspect the server's current request's HTTP environment.
648 * Retrieve the current HTTP request's body.
650 * @param string $body_class_name A user class extending http\Message\Body.
651 * @throws \http\Exception\InvalidArgumentException
652 * @throws \http\Exception\UnexpectedValueException
653 * @return \http\Message\Body instance representing the request body
655 function getRequestBody(string $body_class_name = NULL) {}
657 * Retrieve one or all headers of the current HTTP request.
659 * @param string $header_name The key of a header to retrieve.
660 * @return NULL|string|array NULL if $header_name was not found
661 * or string the compound header when $header_name was found
662 * or array of all headers if $header_name was not specified
664 function getRequestHeader(string $header_name = NULL) {}
666 * Get the HTTP response code to send.
668 * @return int the HTTP response code.
670 function getResponseCode() {}
672 * Get one or all HTTP response headers to be sent.
674 * @param string $header_name The name of the response header to retrieve.
675 * @return string|NULL|array string the compound value of the response header to send
676 * or NULL if the header was not found
677 * or array of all response headers, if $header_name was not specified
679 function getResponseHeader(string $header_name = NULL) {}
681 * Retrieve a list of all known HTTP response status.
683 * @return array mapping of the form \[
685 * int $code => string $status
689 function getResponseStatusForAllCodes() {}
691 * Retrieve the string representation of specified HTTP response code.
693 * @param int $code The HTTP response code to get the string representation for.
694 * @return string the HTTP response status message (may be empty, if no message for this code was found)
696 function getResponseStatusForCode(int $code) {}
698 * Generic negotiator. For specific client negotiation see http\Env::negotiateContentType() and related methods.
701 * > The first element of $supported serves as a default if no operand matches.
703 * @param string $params HTTP header parameter's value to negotiate.
704 * @param array $supported List of supported negotiation operands.
705 * @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.).
706 * @param array $result Out parameter recording negotiation results.
707 * @return NULL|string NULL if negotiation fails.
708 * or string the closest match negotiated, or the default (first entry of $supported).
710 function negotiate(string $params, array $supported, string $prim_typ_sep = NULL, array &$result = NULL) {}
712 * Negotiate the client's preferred character set.
715 * > The first element of $supported character sets serves as a default if no character set matches.
717 * @param array $supported List of supported content character sets.
718 * @param array $result Out parameter recording negotiation results.
719 * @return NULL|string NULL if negotiation fails.
720 * or string the negotiated character set.
722 function negotiateCharset(array $supported, array &$result = NULL) {}
724 * Negotiate the client's preferred MIME content type.
727 * > The first element of $supported content types serves as a default if no content-type matches.
729 * @param array $supported List of supported MIME content types.
730 * @param array $result Out parameter recording negotiation results.
731 * @return NULL|string NULL if negotiation fails.
732 * or string the negotiated content type.
734 function negotiateContentType(array $supported, array &$result = NULL) {}
736 * Negotiate the client's preferred encoding.
739 * > The first element of $supported encodings serves as a default if no encoding matches.
741 * @param array $supported List of supported content encodings.
742 * @param array $result Out parameter recording negotiation results.
743 * @return NULL|string NULL if negotiation fails.
744 * or string the negotiated encoding.
746 function negotiateEncoding(array $supported, array &$result = NULL) {}
748 * Negotiate the client's preferred language.
751 * > The first element of $supported languages serves as a default if no language matches.
753 * @param array $supported List of supported content languages.
754 * @param array $result Out parameter recording negotiation results.
755 * @return NULL|string NULL if negotiation fails.
756 * or string the negotiated language.
758 function negotiateLanguage(array $supported, array &$result = NULL) {}
760 * Set the HTTP response code to send.
762 * @param int $code The HTTP response status code.
763 * @return bool Success.
765 function setResponseCode(int $code) {}
767 * Set a response header, either replacing a prior set header, or appending the new header value, depending on $replace.
769 * 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.
771 * If $response_code is not 0, the response status code is updated accordingly.
773 * @param string $header_name
774 * @param mixed $header_value
775 * @param int $response_code
776 * @param bool $replace
777 * @return bool Success.
779 function setResponseHeader(string $header_name, $header_value = NULL, int $response_code = NULL, bool $replace = NULL) {}
782 * The http extension's Exception interface.
784 * Use it to catch any Exception thrown by pecl/http.
786 * 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.
788 interface Exception
{
791 * The http\Header class provides methods to manipulate, match, negotiate and serialize HTTP headers.
793 class Header
implements \Serializable
{
795 * None of the following match constraints applies.
797 const MATCH_LOOSE
= 0;
799 * Perform case sensitive matching.
801 const MATCH_CASE
= 1;
803 * Match only on word boundaries (according by CType alpha-numeric).
805 const MATCH_WORD
= 16;
807 * Match the complete string.
809 const MATCH_FULL
= 32;
811 * Case sensitively match the full string (same as MATCH_CASE|MATCH_FULL).
813 const MATCH_STRICT
= 33;
815 * The name of the HTTP header.
822 * The value of the HTTP header.
827 public $value = NULL;
829 * 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.
831 * @param string $name The HTTP header name.
832 * @param mixed $value The value of the header.
836 function __construct(string $name = NULL, $value = NULL) {}
838 * String cast handler. Alias of http\Header::serialize().
840 * @return string the serialized form of the HTTP header (i.e. "Name: value").
842 function __toString() {}
844 * Create a parameter list out of the HTTP header value.
846 * @param mixed $ps The parameter separator(s).
847 * @param mixed $as The argument separator(s).
848 * @param mixed $vs The value separator(s).
849 * @param int $flags The modus operandi. See http\Params constants.
850 * @return \http\Params instance
852 function getParams($ps = NULL, $as = NULL, $vs = NULL, int $flags = NULL) {}
854 * Match the HTTP header's value against provided $value according to $flags.
856 * @param string $value The comparison value.
857 * @param int $flags The modus operandi. See http\Header constants.
858 * @return bool whether $value matches the header value according to $flags.
860 function match(string $value, int $flags = NULL) {}
862 * Negotiate the header's value against a list of supported values in $supported.
863 * Negotiation operation is adopted according to the header name, i.e. if the
864 * header being negotiated is Accept, then a slash is used as primary type
865 * separator, and if the header is Accept-Language respectively, a hyphen is
869 * > The first element of $supported serves as a default if no operand matches.
871 * @param array $supported The list of supported values to negotiate.
872 * @param array $result Out parameter recording the negotiation results.
873 * @return NULL|string NULL if negotiation fails.
874 * or string the closest match negotiated, or the default (first entry of $supported).
876 function negotiate(array $supported, array &$result = NULL) {}
878 * Parse HTTP headers.
879 * See also http\Header\Parser.
881 * @param string $header The complete string of headers.
882 * @param string $header_class A class extending http\Header.
883 * @return array|false array of parsed headers, where the elements are instances of $header_class if specified.
884 * or false if parsing fails.
886 function parse(string $header, string $header_class = NULL) {}
888 * Implements Serializable.
890 * @return string serialized representation of HTTP header (i.e. "Name: value")
892 function serialize() {}
894 * Convenience method. Alias of http\Header::serialize().
896 * @return string the serialized form of the HTTP header (i.e. "Name: value").
898 function toString() {}
900 * Implements Serializable.
902 * @param string $serialized The serialized HTTP header (i.e. "Name: value")
904 function unserialize($serialized) {}
907 * The message class builds the foundation for any request and response message.
909 * See http\Client\Request and http\Client\Response, as well as http\Env\Request and http\Env\Response.
911 class Message
implements \Countable
, \Serializable
, \Iterator
{
913 * No specific type of message.
919 const TYPE_REQUEST
= 1;
921 * A response message.
923 const TYPE_RESPONSE
= 2;
925 * The message type. See http\Message::TYPE_* constants.
930 protected $type = \http\Message
::TYPE_NONE
;
932 * The message's body.
935 * @var \http\Message\Body
937 protected $body = NULL;
939 * The request method if the message is of type request.
944 protected $requestMethod = "";
946 * The request url if the message is of type request.
951 protected $requestUrl = "";
953 * The response status phrase if the message is of type response.
958 protected $responseStatus = "";
960 * The response code if the message is of type response.
965 protected $responseCode = 0;
967 * A custom HTTP protocol version.
972 protected $httpVersion = NULL;
974 * Any message headers.
979 protected $headers = NULL;
981 * Any parent message.
986 protected $parentMessage;
988 * Create a new HTTP message.
990 * @param mixed $message Either a resource or a string, representing the HTTP message.
991 * @param bool $greedy Whether to read from a $message resource until EOF.
992 * @throws \http\Exception\InvalidArgumentException
993 * @throws \http\Exception\BadMessageException
995 function __construct($message = NULL, bool $greedy = true) {}
997 * Retrieve the message serialized to a string.
998 * Alias of http\Message::toString().
1000 * @return string the single serialized HTTP message.
1002 function __toString() {}
1004 * Append the data of $body to the message's body.
1005 * See http\Message::setBody() and http\Message\Body::append().
1007 * @param \http\Message\Body $body The message body to add.
1008 * @return \http\Message self.
1010 function addBody(\http\Message\Body
$body) {}
1012 * Add an header, appending to already existing headers.
1013 * See http\Message::addHeaders() and http\Message::setHeader().
1015 * @param string $name The header name.
1016 * @param mixed $value The header value.
1017 * @return \http\Message self.
1019 function addHeader(string $name, $value) {}
1021 * Add headers, optionally appending values, if header keys already exist.
1022 * See http\Message::addHeader() and http\Message::setHeaders().
1024 * @param array $headers The HTTP headers to add.
1025 * @param bool $append Whether to append values for existing headers.
1026 * @return \http\Message self.
1028 function addHeaders(array $headers, bool $append = false) {}
1030 * Implements Countable.
1032 * @return int the count of messages in the chain above the current message.
1036 * Implements iterator.
1037 * See http\Message::valid() and http\Message::rewind().
1039 * @return \http\Message the current message in the iterated message chain.
1041 function current() {}
1043 * Detach a clone of this message from any message chain.
1045 * @throws \http\Exception\InvalidArgumentException
1046 * @return \http\Message clone.
1048 function detach() {}
1050 * Retrieve the message's body.
1051 * See http\Message::setBody().
1053 * @throws \http\Exception\InvalidArgumentException
1054 * @throws \http\Exception\UnexpectedValueException
1055 * @return \http\Message\Body the message body.
1057 function getBody() {}
1059 * Retrieve a single header, optionally hydrated into a http\Header extending class.
1061 * @param string $header The header's name.
1062 * @param string $into_class The name of a class extending http\Header.
1063 * @return mixed|\http\Header mixed the header value if $into_class is NULL.
1064 * or \http\Header descendant.
1066 function getHeader(string $header, string $into_class = NULL) {}
1068 * Retrieve all message headers.
1069 * See http\Message::setHeaders() and http\Message::getHeader().
1071 * @return array the message's headers.
1073 function getHeaders() {}
1075 * Retrieve the HTTP protocol version of the message.
1076 * See http\Message::setHttpVersion().
1078 * @return string the HTTP protocol version, e.g. "1.0"; defaults to "1.1".
1080 function getHttpVersion() {}
1082 * Retrieve the first line of a request or response message.
1083 * See http\Message::setInfo and also:
1085 * * http\Message::getType()
1086 * * http\Message::getHttpVersion()
1087 * * http\Message::getResponseCode()
1088 * * http\Message::getResponseStatus()
1089 * * http\Message::getRequestMethod()
1090 * * http\Message::getRequestUrl()
1092 * @return string|NULL string the HTTP message information.
1093 * or NULL if the message is neither of type request nor response.
1095 function getInfo() {}
1097 * Retrieve any parent message.
1098 * See http\Message::reverse().
1100 * @throws \http\Exception\InvalidArgumentException
1101 * @throws \http\Exception\BadMethodCallException
1102 * @return \http\Message the parent message.
1104 function getParentMessage() {}
1106 * Retrieve the request method of the message.
1107 * See http\Message::setRequestMethod() and http\Message::getRequestUrl().
1109 * @return string|false string the request method.
1110 * or false if the message was not of type request.
1112 function getRequestMethod() {}
1114 * Retrieve the request URL of the message.
1115 * See http\Message::setRequestUrl().
1117 * @return string|false string the request URL; usually the path and the querystring.
1118 * or false if the message was not of type request.
1120 function getRequestUrl() {}
1122 * Retrieve the response code of the message.
1123 * See http\Message::setResponseCode() and http\Message::getResponseStatus().
1125 * @return int|false int the response status code.
1126 * or false if the message is not of type response.
1128 function getResponseCode() {}
1130 * Retrieve the response status of the message.
1131 * See http\Message::setResponseStatus() and http\Message::getResponseCode().
1133 * @return string|false string the response status phrase.
1134 * or false if the message is not of type response.
1136 function getResponseStatus() {}
1138 * Retrieve the type of the message.
1139 * See http\Message::setType() and http\Message::getInfo().
1141 * @return int the message type. See http\Message::TYPE_* constants.
1143 function getType() {}
1145 * Check whether this message is a multipart message based on it's content type.
1146 * 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.
1148 * See http\Message::splitMultipartBody().
1150 * @param string $boundary A reference where the boundary string will be stored.
1151 * @return bool whether this is a message with a multipart "Content-Type".
1153 function isMultipart(string &$boundary = NULL) {}
1155 * Implements Iterator.
1156 * See http\Message::current() and http\Message::rewind().
1158 * @return int a non-sequential integer key.
1162 * Implements Iterator.
1163 * See http\Message::valid() and http\Message::rewind().
1167 * Prepend message(s) $message to this message, or the top most message of this message chain.
1170 * > The message chains must not overlap.
1172 * @param \http\Message $message The message (chain) to prepend as parent messages.
1173 * @param bool $top Whether to prepend to the top-most parent message.
1174 * @throws \http\Exception\InvalidArgumentException
1175 * @throws \http\Exception\UnexpectedValueException
1176 * @return \http\Message self.
1178 function prepend(\http\Message
$message, bool $top = true) {}
1180 * Reverse the message chain and return the former top-most message.
1183 * > 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.
1185 * > This call re-orders the messages of the chain and returns the message that was parsed first with any later parsed messages re-parentized.
1187 * @throws \http\Exception\InvalidArgumentException
1188 * @return \http\Message the other end of the message chain.
1190 function reverse() {}
1192 * Implements Iterator.
1194 function rewind() {}
1196 * Implements Serializable.
1198 * @return string the serialized HTTP message.
1200 function serialize() {}
1202 * Set the message's body.
1203 * See http\Message::getBody() and http\Message::addBody().
1205 * @param \http\Message\Body $body The new message body.
1206 * @throws \http\Exception\InvalidArgumentException
1207 * @throws \http\Exception\UnexpectedValueException
1208 * @return \http\Message self.
1210 function setBody(\http\Message\Body
$body) {}
1212 * Set a single header.
1213 * See http\Message::getHeader() and http\Message::addHeader().
1216 * > Prior to v2.5.6/v3.1.0 headers with the same name were merged into a single
1217 * > header with values concatenated by comma.
1219 * @param string $header The header's name.
1220 * @param mixed $value The header's value. Removes the header if NULL.
1221 * @return \http\Message self.
1223 function setHeader(string $header, $value = NULL) {}
1225 * Set the message headers.
1226 * See http\Message::getHeaders() and http\Message::addHeaders().
1229 * > Prior to v2.5.6/v3.1.0 headers with the same name were merged into a single
1230 * > header with values concatenated by comma.
1232 * @param array $headers The message's headers.
1233 * @return \http\Message null.
1235 function setHeaders(array $headers = NULL) {}
1237 * Set the HTTP protocol version of the message.
1238 * See http\Message::getHttpVersion().
1240 * @param string $http_version The protocol version, e.g. "1.1", optionally prefixed by "HTTP/".
1241 * @throws \http\Exception\InvalidArgumentException
1242 * @throws \http\Exception\BadHeaderException
1243 * @return \http\Message self.
1245 function setHttpVersion(string $http_version) {}
1247 * Set the complete message info, i.e. type and response resp. request information, at once.
1248 * See http\Message::getInfo().
1250 * @param string $http_info The message info (first line of an HTTP message).
1251 * @throws \http\Exception\InvalidArgumentException
1252 * @throws \http\Exception\BadHeaderException
1253 * @return \http\Message self.
1255 function setInfo(string $http_info) {}
1257 * Set the request method of the message.
1258 * See http\Message::getRequestMethod() and http\Message::setRequestUrl().
1260 * @param string $method The request method.
1261 * @throws \http\Exception\InvalidArgumentException
1262 * @throws \http\Exception\BadMethodCallException
1263 * @return \http\Message self.
1265 function setRequestMethod(string $method) {}
1267 * Set the request URL of the message.
1268 * See http\Message::getRequestUrl() and http\Message::setRequestMethod().
1270 * @param string $url The request URL.
1271 * @throws \http\Exception\InvalidArgumentException
1272 * @throws \http\Exception\BadMethodCallException
1273 * @return \http\Message self.
1275 function setRequestUrl(string $url) {}
1277 * Set the response status code.
1278 * See http\Message::getResponseCode() and http\Message::setResponseStatus().
1281 * > This method also resets the response status phrase to the default for that code.
1283 * @param int $response_code The response code.
1284 * @param bool $strict Whether to check that the response code is between 100 and 599 inclusive.
1285 * @throws \http\Exception\InvalidArgumentException
1286 * @throws \http\Exception\BadMethodCallException
1287 * @return \http\Message self.
1289 function setResponseCode(int $response_code, bool $strict = true) {}
1291 * Set the response status phrase.
1292 * See http\Message::getResponseStatus() and http\Message::setResponseCode().
1294 * @param string $response_status The status phrase.
1295 * @throws \http\Exception\InvalidArgumentException
1296 * @throws \http\Exception\BadMethodCallException
1297 * @return \http\Message self.
1299 function setResponseStatus(string $response_status) {}
1301 * Set the message type and reset the message info.
1302 * See http\Message::getType() and http\Message::setInfo().
1304 * @param int $type The desired message type. See the http\Message::TYPE_* constants.
1305 * @return \http\Message self.
1307 function setType(int $type) {}
1309 * Splits the body of a multipart message.
1310 * See http\Message::isMultipart() and http\Message\Body::addPart().
1312 * @throws \http\Exception\InvalidArgumentException
1313 * @throws \http\Exception\BadMethodCallException
1314 * @throws \http\Exception\BadMessageException
1315 * @return \http\Message a message chain of all messages of the multipart body.
1317 function splitMultipartBody() {}
1319 * Stream the message through a callback.
1321 * @param callable $callback The callback of the form function(http\Message $from, string $data).
1322 * @return \http\Message self.
1324 function toCallback(callable
$callback) {}
1326 * Stream the message into stream $stream, starting from $offset, streaming $maxlen at most.
1328 * @param resource $stream The resource to write to.
1329 * @return \http\Message self.
1331 function toStream($stream) {}
1333 * Retrieve the message serialized to a string.
1335 * @param bool $include_parent Whether to include all parent messages.
1336 * @return string the HTTP message chain serialized to a string.
1338 function toString(bool $include_parent = false) {}
1340 * Implements Serializable.
1342 * @param string $data The serialized message.
1344 function unserialize($data) {}
1346 * Implements Iterator.
1347 * See http\Message::current() and http\Message::rewind().
1349 * @return bool whether http\Message::current() would not return NULL.
1354 * Parse, interpret and compose HTTP (header) parameters.
1356 class Params
implements \ArrayAccess
{
1358 * The default parameter separator (",").
1360 const DEF_PARAM_SEP
= ',';
1362 * The default argument separator (";").
1364 const DEF_ARG_SEP
= ';';
1366 * The default value separator ("=").
1368 const DEF_VAL_SEP
= '=';
1370 * Empty param separator to parse cookies.
1372 const COOKIE_PARAM_SEP
= '';
1374 * Do not interpret the parsed parameters.
1376 const PARSE_RAW
= 0;
1378 * Interpret input as default formatted parameters.
1380 const PARSE_DEFAULT
= 17;
1382 * Parse backslash escaped (quoted) strings.
1384 const PARSE_ESCAPED
= 1;
1386 * Urldecode single units of parameters, arguments and values.
1388 const PARSE_URLENCODED
= 4;
1390 * Parse sub dimensions indicated by square brackets.
1392 const PARSE_DIMENSION
= 8;
1394 * Parse URL querystring (same as http\Params::PARSE_URLENCODED|http\Params::PARSE_DIMENSION).
1396 const PARSE_QUERY
= 12;
1398 * Parse [RFC5987](http://tools.ietf.org/html/rfc5987) style encoded character set and language information embedded in HTTP header params.
1400 const PARSE_RFC5987
= 16;
1402 * Parse [RFC5988](http://tools.ietf.org/html/rfc5988) (Web Linking) tags of Link headers.
1404 const PARSE_RFC5988
= 32;
1406 * The (parsed) parameters.
1411 public $params = NULL;
1413 * The parameter separator(s).
1418 public $param_sep = \http\Params
::DEF_PARAM_SEP
;
1420 * The argument separator(s).
1425 public $arg_sep = \http\Params
::DEF_ARG_SEP
;
1427 * The value separator(s).
1432 public $val_sep = \http\Params
::DEF_VAL_SEP
;
1434 * The modus operandi of the parser. See http\Params::PARSE_* constants.
1439 public $flags = \http\Params
::PARSE_DEFAULT
;
1441 * Instantiate a new HTTP (header) parameter set.
1443 * @param mixed $params Pre-parsed parameters or a string to be parsed.
1444 * @param mixed $ps The parameter separator(s).
1445 * @param mixed $as The argument separator(s).
1446 * @param mixed $vs The value separator(s).
1447 * @param int $flags The modus operandi. See http\Params::PARSE_* constants.
1448 * @throws \http\Exception\InvalidArgumentException
1449 * @throws \http\Exception\RuntimeException
1451 function __construct($params = NULL, $ps = NULL, $as = NULL, $vs = NULL, int $flags = NULL) {}
1453 * String cast handler. Alias of http\Params::toString().
1454 * Returns a stringified version of the parameters.
1456 * @return string version of the parameters.
1458 function __toString() {}
1460 * Implements ArrayAccess.
1462 * @param string $name The offset to look after.
1463 * @return bool Existence.
1465 function offsetExists($name) {}
1467 * Implements ArrayAccess.
1469 * @param string $name The offset to retrieve.
1470 * @return mixed contents at offset.
1472 function offsetGet($name) {}
1474 * Implements ArrayAccess.
1476 * @param string $name The offset to modify.
1477 * @param mixed $value The value to set.
1479 function offsetSet($name, $value) {}
1481 * Implements ArrayAccess.
1483 * @param string $name The offset to delete.
1485 function offsetUnset($name) {}
1487 * Convenience method that simply returns http\Params::$params.
1489 * @return array of parameters.
1491 function toArray() {}
1493 * Returns a stringified version of the parameters.
1495 * @return string version of the parameters.
1497 function toString() {}
1500 * The http\QueryString class provides versatile facilities to retrieve, use and manipulate query strings and form data.
1502 class QueryString
implements \Serializable
, \ArrayAccess
, \IteratorAggregate
{
1504 * Cast requested value to bool.
1506 const TYPE_BOOL
= 16;
1508 * Cast requested value to int.
1512 * Cast requested value to float.
1514 const TYPE_FLOAT
= 5;
1516 * Cast requested value to string.
1518 const TYPE_STRING
= 6;
1520 * Cast requested value to an array.
1522 const TYPE_ARRAY
= 7;
1524 * Cast requested value to an object.
1526 const TYPE_OBJECT
= 8;
1528 * The global instance. See http\QueryString::getGlobalInstance().
1531 * @var \http\QueryString
1533 private $instance = NULL;
1540 private $queryArray = NULL;
1542 * Create an independent querystring instance.
1544 * @param mixed $params The query parameters to use or parse.
1545 * @throws \http\Exception\BadQueryStringException
1547 function __construct($params = NULL) {}
1549 * Get the string representation of the querystring (x-www-form-urlencoded).
1551 * @return string the x-www-form-urlencoded querystring.
1553 function __toString() {}
1555 * Retrieve an querystring value.
1557 * See http\QueryString::TYPE_* constants.
1559 * @param string $name The key to retrieve the value for.
1560 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
1561 * @param mixed $defval The default value to return if the key $name does not exist.
1562 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
1563 * @return \http\QueryString|string|mixed|mixed|string \http\QueryString if called without arguments.
1564 * or string the whole querystring if $name is of zero length.
1565 * or mixed $defval if the key $name does not exist.
1566 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
1567 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
1569 function get(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
1571 * Retrieve an array value with at offset $name.
1573 * @param string $name The key to look up.
1574 * @param mixed $defval The default value to return if the offset $name does not exist.
1575 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1576 * @return array|mixed array the (casted) value.
1577 * or mixed $defval if offset $name does not exist.
1579 function getArray(string $name, $defval = NULL, bool $delete = false) {}
1581 * Retrieve a boolean value at offset $name.
1583 * @param string $name The key to look up.
1584 * @param mixed $defval The default value to return if the offset $name does not exist.
1585 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1586 * @return bool|mixed bool the (casted) value.
1587 * or mixed $defval if offset $name does not exist.
1589 function getBool(string $name, $defval = NULL, bool $delete = false) {}
1591 * Retrieve a float value at offset $name.
1593 * @param string $name The key to look up.
1594 * @param mixed $defval The default value to return if the offset $name does not exist.
1595 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1596 * @return float|mixed float the (casted) value.
1597 * or mixed $defval if offset $name does not exist.
1599 function getFloat(string $name, $defval = NULL, bool $delete = false) {}
1601 * Retrieve the global querystring instance referencing $_GET.
1603 * @throws \http\Exception\UnexpectedValueException
1604 * @return \http\QueryString the http\QueryString::$instance
1606 function getGlobalInstance() {}
1608 * Retrieve a int value at offset $name.
1610 * @param string $name The key to look up.
1611 * @param mixed $defval The default value to return if the offset $name does not exist.
1612 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1613 * @return int|mixed int the (casted) value.
1614 * or mixed $defval if offset $name does not exist.
1616 function getInt(string $name, $defval = NULL, bool $delete = false) {}
1618 * Implements IteratorAggregate.
1620 * @throws \http\Exception\InvalidArgumentException
1621 * @throws \InvalidArgumentException
1623 function getIterator() {}
1625 * Retrieve a object value with at offset $name.
1627 * @param string $name The key to look up.
1628 * @param mixed $defval The default value to return if the offset $name does not exist.
1629 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1630 * @return object|mixed object the (casted) value.
1631 * or mixed $defval if offset $name does not exist.
1633 function getObject(string $name, $defval = NULL, bool $delete = false) {}
1635 * Retrieve a string value with at offset $name.
1637 * @param string $name The key to look up.
1638 * @param mixed $defval The default value to return if the offset $name does not exist.
1639 * @param bool $delete Whether to remove the key and value from the querystring after retrieval.
1640 * @return string|mixed string the (casted) value.
1641 * or mixed $defval if offset $name does not exist.
1643 function getString(string $name, $defval = NULL, bool $delete = false) {}
1645 * Set additional $params to a clone of this instance.
1646 * See http\QueryString::set().
1649 * > This method returns a clone (copy) of this instance.
1651 * @param mixed $params Additional params as object, array or string to parse.
1652 * @throws \http\Exception\BadQueryStringException
1653 * @return \http\QueryString clone.
1655 function mod($params = NULL) {}
1657 * Implements ArrayAccess.
1659 * @param string $name The offset to look up.
1660 * @return bool whether the key $name isset.
1662 function offsetExists($name) {}
1664 * Implements ArrayAccess.
1666 * @param mixed $offset The offset to look up.
1667 * @return mixed|NULL mixed the value locate at offset $name.
1668 * or NULL if key $name could not be found.
1670 function offsetGet($offset) {}
1672 * Implements ArrayAccess.
1674 * @param string $name The key to set the value for.
1675 * @param mixed $data The data to place at offset $name.
1677 function offsetSet($name, $data) {}
1679 * Implements ArrayAccess.
1681 * @param string $name The offset to look up.
1683 function offsetUnset($name) {}
1685 * Implements Serializable.
1686 * See http\QueryString::toString().
1688 * @return string the x-www-form-urlencoded querystring.
1690 function serialize() {}
1692 * Set additional querystring entries.
1694 * @param mixed $params Additional params as object, array or string to parse.
1695 * @return \http\QueryString self.
1697 function set($params) {}
1699 * Simply returns http\QueryString::$queryArray.
1701 * @return array the $queryArray property.
1703 function toArray() {}
1705 * Get the string representation of the querystring (x-www-form-urlencoded).
1707 * @return string the x-www-form-urlencoded querystring.
1709 function toString() {}
1711 * Implements Serializable.
1713 * @param string $serialized The x-www-form-urlencoded querystring.
1714 * @throws \http\Exception
1716 function unserialize($serialized) {}
1718 * Translate character encodings of the querystring with ext/iconv.
1721 * > This method is only available when ext/iconv support was enabled at build time.
1723 * @param string $from_enc The encoding to convert from.
1724 * @param string $to_enc The encoding to convert to.
1725 * @throws \http\Exception\InvalidArgumentException
1726 * @throws \http\Exception\BadConversionException
1727 * @return \http\QueryString self.
1729 function xlate(string $from_enc, string $to_enc) {}
1732 * The http\Url class provides versatile means to parse, construct and manipulate URLs.
1736 * Replace parts of the old URL with parts of the new.
1740 * Whether a relative path should be joined into the old path.
1742 const JOIN_PATH
= 1;
1744 * Whether the querystrings should be joined.
1746 const JOIN_QUERY
= 2;
1748 * Strip the user information from the URL.
1750 const STRIP_USER
= 4;
1752 * Strip the password from the URL.
1754 const STRIP_PASS
= 8;
1756 * Strip user and password information from URL (same as STRIP_USER|STRIP_PASS).
1758 const STRIP_AUTH
= 12;
1760 * Do not include the port.
1762 const STRIP_PORT
= 32;
1764 * Do not include the URL path.
1766 const STRIP_PATH
= 64;
1768 * Do not include the URL querystring.
1770 const STRIP_QUERY
= 128;
1772 * Strip the fragment (hash) from the URL.
1774 const STRIP_FRAGMENT
= 256;
1776 * Strip everything except scheme and host information.
1778 const STRIP_ALL
= 492;
1780 * Import initial URL parts from the SAPI environment.
1782 const FROM_ENV
= 4096;
1784 * Whether to sanitize the URL path (consolidate double slashes, directory jumps etc.)
1786 const SANITIZE_PATH
= 8192;
1788 * Parse UTF-8 encoded multibyte sequences.
1790 const PARSE_MBUTF8
= 131072;
1792 * Parse locale encoded multibyte sequences (on systems with wide character support).
1794 const PARSE_MBLOC
= 65536;
1796 * Parse and convert multibyte hostnames according to IDNA (with IDNA support).
1798 const PARSE_TOIDN
= 1048576;
1800 * Explicitly request IDNA2003 implementation if available (libidn, idnkit or ICU).
1802 const PARSE_TOIDN_2003
= 9437184;
1804 * Explicitly request IDNA2008 implementation if available (libidn2, idnkit2 or ICU).
1806 const PARSE_TOIDN_2008
= 5242880;
1808 * Percent encode multibyte sequences in the userinfo, path, query and fragment parts of the URL.
1810 const PARSE_TOPCT
= 2097152;
1812 * Continue parsing when encountering errors.
1814 const IGNORE_ERRORS
= 268435456;
1816 * Suppress errors/exceptions.
1818 const SILENT_ERRORS
= 536870912;
1820 * Standard flags used by default internally for e.g. http\Message::setRequestUrl().
1821 * Enables joining path and query, sanitizing path, multibyte/unicode, international domain names and transient percent encoding.
1823 const STDFLAGS
= 3350531;
1830 public $scheme = NULL;
1832 * Authenticating user.
1837 public $user = NULL;
1839 * Authentication password.
1844 public $pass = NULL;
1851 public $host = NULL;
1858 public $port = NULL;
1865 public $path = NULL;
1872 public $query = NULL;
1874 * URL fragment (hash).
1879 public $fragment = NULL;
1881 * Create an instance of an http\Url.
1884 * > Prior to v3.0.0, the default for the $flags parameter was http\Url::FROM_ENV.
1886 * See also http\Env\Url.
1888 * @param mixed $old_url Initial URL parts. Either an array, object, http\Url instance or string to parse.
1889 * @param mixed $new_url Overriding URL parts. Either an array, object, http\Url instance or string to parse.
1890 * @param int $flags The modus operandi of constructing the url. See http\Url constants.
1891 * @throws \http\Exception\InvalidArgumentException
1892 * @throws \http\Exception\BadUrlException
1894 function __construct($old_url = NULL, $new_url = NULL, int $flags = 0) {}
1896 * String cast handler. Alias of http\Url::toString().
1898 * @return string the URL as string.
1900 function __toString() {}
1902 * Clone this URL and apply $parts to the cloned URL.
1905 * > This method returns a clone (copy) of this instance.
1907 * @param mixed $parts New URL parts.
1908 * @param int $flags Modus operandi of URL construction. See http\Url constants.
1909 * @throws \http\Exception\InvalidArgumentException
1910 * @throws \http\Exception\BadUrlException
1911 * @return \http\Url clone.
1913 function mod($parts, int $flags = \http\Url
::JOIN_PATH|http\Url
::JOIN_QUERY|http\Url
::SANITIZE_PATH
) {}
1915 * Retrieve the URL parts as array.
1917 * @return array the URL parts.
1919 function toArray() {}
1921 * Get the string prepresentation of the URL.
1923 * @return string the URL as string.
1925 function toString() {}
1928 * The http\Client\Curl namespace holds option value constants specific to the curl driver of the http\Client.
1930 namespace http\Client\Curl
;
1932 * Bitmask of available libcurl features.
1933 * See http\Client\Curl\Features namespace.
1935 const FEATURES
= 4179869;
1937 * List of library versions of or linked into libcurl,
1938 * e.g. "libcurl/7.50.0 OpenSSL/1.0.2h zlib/1.2.8 libidn/1.32 nghttp2/1.12.0".
1939 * See http\Client\Curl\Versions namespace.
1941 const VERSIONS
= 'libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3';
1943 * Use HTTP/1.0 protocol version.
1945 const HTTP_VERSION_1_0
= 1;
1947 * Use HTTP/1.1 protocol version.
1949 const HTTP_VERSION_1_1
= 2;
1951 * Attempt to use HTTP/2 protocol version. Available if libcurl is v7.33.0 or more recent and was built with nghttp2 support.
1953 const HTTP_VERSION_2_0
= 3;
1955 * Attempt to use version 2 for HTTPS, version 1.1 for HTTP. Available if libcurl is v7.47.0 or more recent and was built with nghttp2 support.
1957 const HTTP_VERSION_2TLS
= 4;
1959 * Use any HTTP protocol version.
1961 const HTTP_VERSION_ANY
= 0;
1963 * Use TLS v1.0 encryption.
1965 const SSL_VERSION_TLSv1_0
= 4;
1967 * Use TLS v1.1 encryption.
1969 const SSL_VERSION_TLSv1_1
= 5;
1971 * Use TLS v1.2 encryption.
1973 const SSL_VERSION_TLSv1_2
= 6;
1975 * Use any TLS v1 encryption.
1977 const SSL_VERSION_TLSv1
= 1;
1979 * Use SSL v2 encryption.
1981 const SSL_VERSION_SSLv2
= 2;
1983 * Use SSL v3 encryption.
1985 const SSL_VERSION_SSLv3
= 3;
1987 * Use any encryption.
1989 const SSL_VERSION_ANY
= 0;
1991 * 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.
1993 const TLSAUTH_SRP
= 1;
1995 * Use IPv4 resolver.
1997 const IPRESOLVE_V4
= 1;
1999 * Use IPv6 resolver.
2001 const IPRESOLVE_V6
= 2;
2005 const IPRESOLVE_ANY
= 0;
2007 * Use Basic authentication.
2009 const AUTH_BASIC
= 1;
2011 * Use Digest authentication.
2013 const AUTH_DIGEST
= 2;
2015 * Use IE (lower v7) quirks with Digest authentication. Available if libcurl is v7.19.3 or more recent.
2017 const AUTH_DIGEST_IE
= 16;
2019 * Use NTLM authentication.
2021 const AUTH_NTLM
= 8;
2023 * Use GSS-Negotiate authentication.
2025 const AUTH_GSSNEG
= 4;
2027 * Use HTTP Netgotiate authentication (SPNEGO, RFC4559). Available if libcurl is v7.38.0 or more recent.
2029 const AUTH_SPNEGO
= 4;
2031 * Use any authentication.
2033 const AUTH_ANY
= -17;
2035 * Use SOCKSv4 proxy protocol.
2037 const PROXY_SOCKS4
= 4;
2039 * Use SOCKSv4a proxy protocol.
2041 const PROXY_SOCKS4A
= 5;
2043 * Use SOCKS5h proxy protocol.
2045 const PROXY_SOCKS5_HOSTNAME
= 5;
2047 * Use SOCKS5 proxy protoccol.
2049 const PROXY_SOCKS5
= 5;
2051 * Use HTTP/1.1 proxy protocol.
2053 const PROXY_HTTP
= 0;
2055 * Use HTTP/1.0 proxy protocol. Available if libcurl is v7.19.4 or more recent.
2057 const PROXY_HTTP_1_0
= 1;
2059 * Keep POSTing on 301 redirects. Available if libcurl is v7.19.1 or more recent.
2061 const POSTREDIR_301
= 1;
2063 * Keep POSTing on 302 redirects. Available if libcurl is v7.19.1 or more recent.
2065 const POSTREDIR_302
= 2;
2067 * Keep POSTing on 303 redirects. Available if libcurl is v7.19.1 or more recent.
2069 const POSTREDIR_303
= 4;
2071 * Keep POSTing on any redirect. Available if libcurl is v7.19.1 or more recent.
2073 const POSTREDIR_ALL
= 7;
2074 namespace http\Client
;
2076 * The http\Client\Request class provides an HTTP message implementation tailored to represent a request message to be sent by the client.
2078 * See http\Client::enqueue().
2080 class Request
extends \http\Message
{
2082 * Array of options for this request, which override client options.
2087 protected $options = NULL;
2089 * Create a new client request message to be enqueued and sent by http\Client.
2091 * @param string $meth The request method.
2092 * @param string $url The request URL.
2093 * @param array $headers HTTP headers.
2094 * @param \http\Message\Body $body Request body.
2095 * @throws \http\Exception\InvalidArgumentException
2096 * @throws \http\Exception\UnexpectedValueException
2098 function __construct(string $meth = NULL, string $url = NULL, array $headers = NULL, \http\Message\Body
$body = NULL) {}
2100 * Add querystring data.
2101 * See http\Client\Request::setQuery() and http\Message::setRequestUrl().
2103 * @param mixed $query_data Additional querystring data.
2104 * @throws \http\Exception\InvalidArgumentException
2105 * @throws \http\Exception\BadQueryStringException
2106 * @return \http\Client\Request self.
2108 function addQuery($query_data) {}
2110 * Add specific SSL options.
2111 * See http\Client\Request::setSslOptions(), http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2113 * @param array $ssl_options Add this SSL options.
2114 * @throws \http\Exception\InvalidArgumentException
2115 * @return \http\Client\Request self.
2117 function addSslOptions(array $ssl_options = NULL) {}
2119 * Extract the currently set "Content-Type" header.
2120 * See http\Client\Request::setContentType().
2122 * @return string|NULL string the currently set content type.
2123 * or NULL if no "Content-Type" header is set.
2125 function getContentType() {}
2127 * Get priorly set options.
2128 * See http\Client\Request::setOptions().
2130 * @return array options.
2132 function getOptions() {}
2134 * Retrieve the currently set querystring.
2136 * @return string|NULL string the currently set querystring.
2137 * or NULL if no querystring is set.
2139 function getQuery() {}
2141 * Retrieve priorly set SSL options.
2142 * See http\Client\Request::getOptions() and http\Client\Request::setSslOptions().
2144 * @return array SSL options.
2146 function getSslOptions() {}
2148 * Set the MIME content type of the request message.
2150 * @param string $content_type The MIME type used as "Content-Type".
2151 * @throws \http\Exception\InvalidArgumentException
2152 * @throws \http\Exception\UnexpectedValueException
2153 * @return \http\Client\Request self.
2155 function setContentType(string $content_type) {}
2157 * Set client options.
2158 * See http\Client::setOptions() and http\Client\Curl.
2160 * Request specific options override general options which were set in the client.
2163 * > Only options specified prior enqueueing a request are applied to the request.
2165 * @param array $options The options to set.
2166 * @throws \http\Exception\InvalidArgumentException
2167 * @return \http\Client\Request self.
2169 function setOptions(array $options = NULL) {}
2171 * (Re)set the querystring.
2172 * See http\Client\Request::addQuery() and http\Message::setRequestUrl().
2174 * @param mixed $query_data
2175 * @throws \http\Exception\InvalidArgumentException
2176 * @throws \http\Exception\BadQueryStringException
2177 * @return \http\Client\Request self.
2179 function setQuery($query_data) {}
2181 * Specifically set SSL options.
2182 * See http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2184 * @param array $ssl_options Set SSL options to this array.
2185 * @throws \http\Exception\InvalidArgumentException
2186 * @return \http\Client\Request self.
2188 function setSslOptions(array $ssl_options = NULL) {}
2191 * The http\Client\Response class represents an HTTP message the client returns as answer from a server to an http\Client\Request.
2193 class Response
extends \http\Message
{
2195 * Extract response cookies.
2196 * Parses any "Set-Cookie" response headers into an http\Cookie list. See http\Cookie::__construct().
2198 * @param int $flags Cookie parser flags.
2199 * @param array $allowed_extras List of keys treated as extras.
2200 * @return array list of http\Cookie instances.
2202 function getCookies(int $flags = 0, array $allowed_extras = NULL) {}
2204 * Retrieve transfer related information after the request has completed.
2205 * See http\Client::getTransferInfo().
2207 * @param string $name A key to retrieve out of the transfer info.
2208 * @throws \http\Exception\InvalidArgumentException
2209 * @throws \http\Exception\BadMethodCallException
2210 * @throws \http\Exception\UnexpectedValueException
2211 * @return object|mixed object stdClass instance with all transfer info if $name was not given.
2212 * or mixed the specific transfer info for $name.
2214 function getTransferInfo(string $name = NULL) {}
2216 namespace http\Client\Curl
;
2218 * Interface to an user event loop implementation for http\Client::configure()'s $use_eventloop option.
2221 * > This interface was added in v2.6.0, resp. v3.1.0.
2227 const POLL_NONE
= 0;
2229 * Poll for read readiness.
2233 * Poll for write readiness.
2237 * Poll for read/write readiness.
2239 const POLL_INOUT
= 3;
2241 * Stop polling for activity on this descriptor.
2243 const POLL_REMOVE
= 4;
2245 * Initialize the event loop.
2247 * @param callable $run as function(http\Client $c, resource $s = null, int $action = http\Client\Curl\User::POLL_NONE) : int
2248 * Internal callback returning the number of unfinished requests pending.
2252 * > The callback should be run when a timeout occurs or a watched socket needs action.
2254 function init(callable
$run);
2256 * Run the loop as long as it does not block.
2259 * > 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.
2266 * > 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.
2270 * Register (or deregister) a socket watcher.
2272 * @param resource $socket The socket descriptor to watch.
2273 * @param int $poll http\Client\Curl\User::POLL_* constant.
2275 function socket($socket, int $poll);
2277 * Register a timeout watcher.
2279 * @param int $timeout_ms Desired maximum timeout in milliseconds.
2281 function timer(int $timeout_ms);
2283 * Wait/poll/select (block the loop) until events fire.
2286 * > 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.
2288 * @param int $timeout_ms Block for at most this milliseconds.
2290 function wait(int $timeout_ms = null);
2293 * CURL feature constants.
2296 * > These constants have been added in v2.6.0, resp. v3.1.0.
2298 namespace http\Client\Curl\Features
;
2300 * Whether libcurl supports asynchronous domain name resolution.
2302 const ASYNCHDNS
= 128;
2304 * Whether libcurl supports the Generic Security Services Application Program Interface. Available if libcurl is v7.38.0 or more recent.
2306 const GSSAPI
= 131072;
2308 * Whether libcurl supports HTTP Generic Security Services negotiation.
2310 const GSSNEGOTIATE
= 32;
2312 * Whether libcurl supports the HTTP/2 protocol. Available if libcurl is v7.33.0 or more recent.
2314 const HTTP2
= 65536;
2316 * Whether libcurl supports international domain names.
2320 * Whether libcurl supports IPv6.
2324 * Whether libcurl supports the old Kerberos protocol.
2326 const KERBEROS4
= 2;
2328 * Whether libcurl supports the more recent Kerberos v5 protocol. Available if libcurl is v7.40.0 or more recent.
2330 const KERBEROS5
= 262144;
2332 * Whether libcurl supports large files.
2334 const LARGEFILE
= 512;
2336 * Whether libcurl supports gzip/deflate compression.
2340 * Whether libcurl supports the NT Lan Manager authentication.
2344 * Whether libcurl supports NTLM delegation to a winbind helper. Available if libcurl is v7.22.0 or more recent.
2346 const NTLM_WB
= 32768;
2348 * Whether libcurl supports the Public Suffix List for cookie host handling. Available if libcurl is v7.47.0 or more recent.
2350 const PSL
= 1048576;
2352 * Whether libcurl supports the Simple and Protected GSSAPI Negotiation Mechanism.
2356 * Whether libcurl supports SSL/TLS protocols.
2360 * Whether libcurl supports the Security Support Provider Interface.
2364 * Whether libcurl supports TLS Secure Remote Password authentication. Available if libcurl is v7.21.4 or more recent.
2366 const TLSAUTH_SRP
= 16384;
2368 * Whether libcurl supports connections to unix sockets. Available if libcurl is v7.40.0 or more recent.
2370 const UNIX_SOCKETS
= 524288;
2372 * CURL version constants.
2375 * > These constants have been added in v2.6.0, resp. v3.1.0.
2377 namespace http\Client\Curl\Versions
;
2379 * Version string of libcurl, e.g. "7.50.0".
2381 const CURL
= '7.64.0';
2383 * Version string of the SSL/TLS library, e.g. "OpenSSL/1.0.2h".
2385 const SSL
= 'OpenSSL/1.1.1d';
2387 * Version string of the zlib compression library, e.g. "1.2.8".
2389 const LIBZ
= '1.2.11';
2391 * Version string of the c-ares library, e.g. "1.11.0".
2395 * Version string of the IDN library, e.g. "1.32".
2398 namespace http\Encoding
;
2400 * Base class for encoding stream implementations.
2402 abstract class Stream
{
2404 * Do no intermittent flushes.
2406 const FLUSH_NONE
= 0;
2408 * Flush at appropriate transfer points.
2410 const FLUSH_SYNC
= 1048576;
2412 * Flush at each IO operation.
2414 const FLUSH_FULL
= 2097152;
2416 * Base constructor for encoding stream implementations.
2418 * @param int $flags See http\Encoding\Stream and implementation specific constants.
2419 * @throws \http\Exception\InvalidArgumentException
2420 * @throws \http\Exception\RuntimeException
2422 function __construct(int $flags = 0) {}
2424 * Check whether the encoding stream is already done.
2426 * @return bool whether the encoding stream is completed.
2430 * Finish and reset the encoding stream.
2431 * Returns any pending data.
2433 * @return string any pending data.
2435 function finish() {}
2437 * Flush the encoding stream.
2438 * Returns any pending data.
2440 * @return string any pending data.
2444 * Update the encoding stream with more input.
2446 * @param string $data The data to pass through the stream.
2447 * @return string processed data.
2449 function update(string $data) {}
2451 namespace http\Encoding\Stream
;
2453 * A [brotli](https://brotli.org) decoding stream.
2456 * > This class has been added in v3.2.0.
2458 class Debrotli
extends \http\Encoding\Stream
{
2460 * Decode brotli encoded data.
2462 * @param string $data The data to uncompress.
2463 * @return string the uncompressed data.
2465 function decode(string $data) {}
2468 * A stream decoding data encoded with chunked transfer encoding.
2470 class Dechunk
extends \http\Encoding\Stream
{
2472 * Decode chunked encoded data.
2474 * @param string $data The data to decode.
2475 * @param int $decoded_len Out parameter with the length of $data that's been decoded.
2476 * Should be ```strlen($data)``` if not truncated.
2477 * @return string|string|string|false string the decoded data.
2478 * or string the unencoded data.
2479 * or string the truncated decoded data.
2480 * or false if $data cannot be decoded.
2482 function decode(string $data, int &$decoded_len = 0) {}
2485 * A deflate stream supporting deflate, zlib and gzip encodings.
2487 class Deflate
extends \http\Encoding\Stream
{
2489 * Gzip encoding. RFC1952
2491 const TYPE_GZIP
= 16;
2493 * Zlib encoding. RFC1950
2495 const TYPE_ZLIB
= 0;
2497 * Deflate encoding. RFC1951
2499 const TYPE_RAW
= 32;
2501 * Default compression level.
2503 const LEVEL_DEF
= 0;
2505 * Least compression level.
2507 const LEVEL_MIN
= 1;
2509 * Greatest compression level.
2511 const LEVEL_MAX
= 9;
2513 * Default compression strategy.
2515 const STRATEGY_DEF
= 0;
2517 * Filtered compression strategy.
2519 const STRATEGY_FILT
= 256;
2521 * Huffman strategy only.
2523 const STRATEGY_HUFF
= 512;
2525 * Run-length encoding strategy.
2527 const STRATEGY_RLE
= 768;
2529 * Encoding with fixed Huffman codes only.
2531 * > **A note on the compression strategy:**
2533 * > The strategy parameter is used to tune the compression algorithm.
2535 * > 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).
2537 * > 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.
2539 * > RLE is designed to be almost as fast as HUFFMAN_ONLY, but give better compression for PNG image data.
2541 * > FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
2543 * > The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately.
2545 * >_Source: [zlib Manual](http://www.zlib.net/manual.html)_
2547 const STRATEGY_FIXED
= 1024;
2549 * Encode data with deflate/zlib/gzip encoding.
2551 * @param string $data The data to compress.
2552 * @param int $flags Any compression tuning flags. See http\Encoding\Stream\Deflate and http\Encoding\Stream constants.
2553 * @return string the compressed data.
2555 function encode(string $data, int $flags = 0) {}
2558 * A [brotli](https://brotli.org) encoding stream.
2561 * > This class has been added in v3.2.0.
2563 class Enbrotli
extends \http\Encoding\Stream
{
2565 * Default compression level.
2567 const LEVEL_DEF
= NULL;
2569 * Least compression level.
2571 const LEVEL_MIN
= NULL;
2573 * Greatest compression level.
2575 const LEVEL_MAX
= NULL;
2577 * Default window bits.
2579 const WBITS_DEF
= NULL;
2581 * Minimum window bits.
2583 const WBITS_MIN
= NULL;
2585 * Maximum window bits.
2587 const WBITS_MAX
= NULL;
2589 * Default compression mode.
2591 const MODE_GENERIC
= NULL;
2593 * Compression mode for UTF-8 formatted text.
2595 const MODE_TEXT
= NULL;
2597 * Compression mode used in WOFF 2.0.
2599 const MODE_FONT
= NULL;
2601 * Encode data with brotli encoding.
2603 * @param string $data The data to compress.
2604 * @param int $flags Any compression tuning flags. See http\Encoding\Stream\Enbrotli and http\Encoding\Stream constants.
2605 * @return string the compressed data.
2607 function encode(string $data, int $flags = 0) {}
2610 * A inflate stream supporting deflate, zlib and gzip encodings.
2612 class Inflate
extends \http\Encoding\Stream
{
2614 * Decode deflate/zlib/gzip encoded data.
2616 * @param string $data The data to uncompress.
2617 * @return string the uncompressed data.
2619 function decode(string $data) {}
2623 * The http\Env\Request class' instances represent the server's current HTTP request.
2625 * See http\Message for inherited members.
2627 class Request
extends \http\Message
{
2629 * The request's query parameters. ($_GET)
2632 * @var \http\QueryString
2634 protected $query = NULL;
2636 * The request's form parameters. ($_POST)
2639 * @var \http\QueryString
2641 protected $form = NULL;
2643 * The request's form uploads. ($_FILES)
2648 protected $files = NULL;
2650 * The request's cookies. ($_COOKIE)
2655 protected $cookie = NULL;
2657 * Create an instance of the server's current HTTP request.
2659 * Upon construction, the http\Env\Request acquires http\QueryString instances of query parameters ($\_GET) and form parameters ($\_POST).
2661 * It also compiles an array of uploaded files ($\_FILES) more comprehensive than the original $\_FILES array, see http\Env\Request::getFiles() for that matter.
2663 * @throws \http\Exception\InvalidArgumentException
2664 * @throws \http\Exception\UnexpectedValueException
2666 function __construct() {}
2668 * Retrieve an URL query value ($_GET).
2670 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2672 * @param string $name The key to retrieve the value for.
2673 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2674 * @param mixed $defval The default value to return if the key $name does not exist.
2675 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2676 * @return \http\QueryString|string|mixed|mixed|string \http\QueryString if called without arguments.
2677 * or string the whole querystring if $name is of zero length.
2678 * or mixed $defval if the key $name does not exist.
2679 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2680 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2682 function getCookie(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2684 * Retrieve the uploaded files list ($_FILES).
2686 * @return array the consolidated upload files array.
2688 function getFiles() {}
2690 * Retrieve a form value ($_POST).
2692 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2694 * @param string $name The key to retrieve the value for.
2695 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2696 * @param mixed $defval The default value to return if the key $name does not exist.
2697 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2698 * @return \http\QueryString|string|mixed|mixed|string \http\QueryString if called without arguments.
2699 * or string the whole querystring if $name is of zero length.
2700 * or mixed $defval if the key $name does not exist.
2701 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2702 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2704 function getForm(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2706 * Retrieve an URL query value ($_GET).
2708 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2710 * @param string $name The key to retrieve the value for.
2711 * @param mixed $type The type to cast the value to. See http\QueryString::TYPE_* constants.
2712 * @param mixed $defval The default value to return if the key $name does not exist.
2713 * @param bool $delete Whether to delete the entry from the querystring after retrieval.
2714 * @return \http\QueryString|string|mixed|mixed|string \http\QueryString if called without arguments.
2715 * or string the whole querystring if $name is of zero length.
2716 * or mixed $defval if the key $name does not exist.
2717 * or mixed the querystring value cast to $type if $type was specified and the key $name exists.
2718 * or string the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
2720 function getQuery(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2723 * The http\Env\Response class' instances represent the server's current HTTP response.
2725 * See http\Message for inherited members.
2727 class Response
extends \http\Message
{
2729 * Do not use content encoding.
2731 const CONTENT_ENCODING_NONE
= 0;
2733 * Support "Accept-Encoding" requests with gzip and deflate encoding.
2735 const CONTENT_ENCODING_GZIP
= 1;
2737 * No caching info available.
2741 * The cache was hit.
2743 const CACHE_HIT
= 1;
2745 * The cache was missed.
2747 const CACHE_MISS
= 2;
2749 * A request instance which overrides the environments default request.
2752 * @var \http\Env\Request
2754 protected $request = NULL;
2756 * The response's MIME content type.
2761 protected $contentType = NULL;
2763 * The response's MIME content disposition.
2768 protected $contentDisposition = NULL;
2770 * See http\Env\Response::CONTENT_ENCODING_* constants.
2775 protected $contentEncoding = NULL;
2777 * How the client should treat this response in regards to caching.
2782 protected $cacheControl = NULL;
2789 protected $etag = NULL;
2791 * A "Last-Modified" time stamp.
2796 protected $lastModified = NULL;
2798 * Any throttling delay.
2803 protected $throttleDelay = NULL;
2805 * The chunk to send every $throttleDelay seconds.
2810 protected $throttleChunk = NULL;
2812 * The response's cookies.
2817 protected $cookies = NULL;
2819 * Create a new env response message instance.
2821 * @throws \http\Exception\InvalidArgumentException
2822 * @throws \http\Exception\UnexpectedValueException
2824 function __construct() {}
2826 * Output buffer handler.
2827 * Appends output data to the body.
2829 * @param string $data The data output.
2830 * @param int $ob_flags Output buffering flags passed from the output buffering control layer.
2831 * @return bool success.
2833 function __invoke(string $data, int $ob_flags = 0) {}
2835 * Manually test the header $header_name of the environment's request for a cache hit.
2836 * http\Env\Response::send() checks that itself, though.
2838 * @param string $header_name The request header to test.
2839 * @return int a http\Env\Response::CACHE_* constant.
2841 function isCachedByEtag(string $header_name = "If-None-Match") {}
2843 * Manually test the header $header_name of the environment's request for a cache hit.
2844 * http\Env\Response::send() checks that itself, though.
2846 * @param string $header_name The request header to test.
2847 * @return int a http\Env\Response::CACHE_* constant.
2849 function isCachedByLastModified(string $header_name = "If-Modified-Since") {}
2851 * Send the response through the SAPI or $stream.
2852 * Flushes all output buffers.
2854 * @param resource $stream A writable stream to send the response through.
2855 * @return bool success.
2857 function send($stream = NULL) {}
2859 * Make suggestions to the client how it should cache the response.
2861 * @param string $cache_control (A) "Cache-Control" header value(s).
2862 * @throws \http\Exception\InvalidArgumentException
2863 * @return \http\Env\Response self.
2865 function setCacheControl(string $cache_control) {}
2867 * Set the reponse's content disposition parameters.
2869 * @param array $disposition_params MIME content disposition as http\Params array.
2870 * @throws \http\Exception\InvalidArgumentException
2871 * @return \http\Env\Response self.
2873 function setContentDisposition(array $disposition_params) {}
2875 * Enable support for "Accept-Encoding" requests with deflate or gzip.
2876 * The response will be compressed if the client indicates support and wishes that.
2878 * @param int $content_encoding See http\Env\Response::CONTENT_ENCODING_* constants.
2879 * @throws \http\Exception\InvalidArgumentException
2880 * @return \http\Env\Response self.
2882 function setContentEncoding(int $content_encoding) {}
2884 * Set the MIME content type of the response.
2886 * @param string $content_type The response's content type.
2887 * @throws \http\Exception\InvalidArgumentException
2888 * @return \http\Env\Response self.
2890 function setContentType(string $content_type) {}
2892 * Add cookies to the response to send.
2894 * @param mixed $cookie The cookie to send.
2895 * @throws \http\Exception\InvalidArgumentException
2896 * @throws \http\Exception\UnexpectedValueException
2897 * @return \http\Env\Response self.
2899 function setCookie($cookie) {}
2901 * Override the environment's request.
2903 * @param \http\Message $env_request The overriding request message.
2904 * @throws \http\Exception\InvalidArgumentException
2905 * @return \http\Env\Response self.
2907 function setEnvRequest(\http\Message
$env_request) {}
2909 * Set a custom ETag.
2912 * > This will be used for caching and pre-condition checks.
2914 * @param string $etag A ETag.
2915 * @throws \http\Exception\InvalidArgumentException
2916 * @return \http\Env\Response self.
2918 function setEtag(string $etag) {}
2920 * Set a custom last modified time stamp.
2923 * > This will be used for caching and pre-condition checks.
2925 * @param int $last_modified A unix timestamp.
2926 * @throws \http\Exception\InvalidArgumentException
2927 * @return \http\Env\Response self.
2929 function setLastModified(int $last_modified) {}
2931 * Enable throttling.
2932 * Send $chunk_size bytes every $delay seconds.
2935 * > 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.
2937 * @param int $chunk_size Bytes to send.
2938 * @param float $delay Seconds to sleep.
2939 * @return \http\Env\Response self.
2941 function setThrottleRate(int $chunk_size, float $delay = 1) {}
2944 * URL class using the HTTP environment by default.
2947 * > This class has been added in v3.0.0.
2949 * Always adds http\Url::FROM_ENV to the $flags constructor argument. See also http\Url.
2951 class Url
extends \http\Url
{
2953 namespace http\Exception
;
2955 * A bad conversion (e.g. character conversion) was encountered.
2957 class BadConversionException
extends \DomainException
implements \http\Exception
{
2960 * A bad HTTP header was encountered.
2962 class BadHeaderException
extends \DomainException
implements \http\Exception
{
2965 * A bad HTTP message was encountered.
2967 class BadMessageException
extends \DomainException
implements \http\Exception
{
2970 * A method was called on an object, which was in an invalid or unexpected state.
2972 class BadMethodCallException
extends \BadMethodCallException
implements \http\Exception
{
2975 * A bad querystring was encountered.
2977 class BadQueryStringException
extends \DomainException
implements \http\Exception
{
2980 * A bad HTTP URL was encountered.
2982 class BadUrlException
extends \DomainException
implements \http\Exception
{
2985 * One or more invalid arguments were passed to a method.
2987 class InvalidArgumentException
extends \InvalidArgumentException
implements \http\Exception
{
2990 * A generic runtime exception.
2992 class RuntimeException
extends \RuntimeException
implements \http\Exception
{
2995 * An unexpected value was encountered.
2997 class UnexpectedValueException
extends \UnexpectedValueException
implements \http\Exception
{
2999 namespace http\Header
;
3001 * The parser which is underlying http\Header and http\Message.
3004 * > This class has been added in v2.3.0.
3008 * Finish up parser at end of (incomplete) input.
3014 const STATE_FAILURE
= -1;
3016 * Expecting HTTP info (request/response line) or headers.
3018 const STATE_START
= 0;
3020 * Expecting a key or already parsing a key.
3022 const STATE_KEY
= 1;
3024 * Expecting a value or already parsing the value.
3026 const STATE_VALUE
= 2;
3028 * At EOL of an header, checking whether a folded header line follows.
3030 const STATE_VALUE_EX
= 3;
3032 * A header was completed.
3034 const STATE_HEADER_DONE
= 4;
3036 * Finished parsing the headers.
3039 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
3041 const STATE_DONE
= 5;
3043 * Retrieve the current state of the parser.
3044 * See http\Header\Parser::STATE_* constants.
3046 * @throws \http\Exception\InvalidArgumentException
3047 * @return int http\Header\Parser::STATE_* constant.
3049 function getState() {}
3053 * @param string $data The (part of the) header to parse.
3054 * @param int $flags Any combination of [parser flags](http/Header/Parser#Parser.flags:).
3055 * @param array $header Successfully parsed headers.
3056 * @throws \http\Exception\InvalidArgumentException
3057 * @return int http\Header\Parser::STATE_* constant.
3059 function parse(string $data, int $flags, array &$header = NULL) {}
3063 * @param resource $stream The header stream to parse from.
3064 * @param int $flags Any combination of [parser flags](http/Header/Parser#Parser.flags:).
3065 * @param array $headers The headers parsed.
3066 * @throws \http\Exception\InvalidArgumentException
3067 * @throws \http\Exception\UnexpectedValueException
3068 * @return int http\Header\Parser::STATE_* constant.
3070 function stream($stream, int $flags, array &$headers) {}
3072 namespace http\Message
;
3074 * The message body, represented as a PHP (temporary) stream.
3077 * > Currently, http\Message\Body::addForm() creates multipart/form-data bodies.
3079 class Body
implements \Serializable
{
3081 * Create a new message body, optionally referencing $stream.
3083 * @param resource $stream A stream to be used as message body.
3084 * @throws \http\Exception\InvalidArgumentException
3085 * @throws \http\Exception\UnexpectedValueException
3087 function __construct($stream = NULL) {}
3089 * String cast handler.
3091 * @return string the message body.
3093 function __toString() {}
3095 * Add form fields and files to the message body.
3098 * > Currently, http\Message\Body::addForm() creates "multipart/form-data" bodies.
3100 * @param array $fields List of form fields to add.
3101 * @param array $files List of form files to add.
3103 * $fields must look like:
3106 * "field_name" => "value",
3107 * "multi_field" => [
3113 * $files must look like:
3117 * "name" => "field_name",
3118 * "type" => "content/type",
3119 * "file" => "/path/to/file.ext"
3121 * "name" => "field_name2",
3122 * "type" => "text/plain",
3123 * "file" => "file.ext",
3124 * "data" => "string"
3126 * "name" => "field_name3",
3127 * "type" => "image/jpeg",
3128 * "file" => "file.ext",
3129 * "data" => fopen("/home/mike/Pictures/mike.jpg","r")
3132 * 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.
3133 * @throws \http\Exception\InvalidArgumentException
3134 * @throws \http\Exception\RuntimeException
3135 * @return \http\Message\Body self.
3137 function addForm(array $fields = NULL, array $files = NULL) {}
3139 * Add a part to a multipart body.
3141 * @param \http\Message $part The message part.
3142 * @throws \http\Exception\InvalidArgumentException
3143 * @throws \http\Exception\RuntimeException
3144 * @return \http\Message\Body self.
3146 function addPart(\http\Message
$part) {}
3148 * Append plain bytes to the message body.
3150 * @param string $data The data to append to the body.
3151 * @throws \http\Exception\InvalidArgumentException
3152 * @throws \http\Exception\RuntimeException
3153 * @return \http\Message\Body self.
3155 function append(string $data) {}
3157 * Retrieve the ETag of the body.
3159 * @return string|string|false string an Apache style ETag of inode, mtime and size in hex concatenated by hyphens if the message body stream is stat-able.
3160 * or string a content hash (which algorithm is determined by INI http.etag.mode) if the stream is not stat-able.
3161 * or false if http.etag.mode is not a known hash algorithm.
3165 * Retrieve any boundary of the message body.
3166 * See http\Message::splitMultipartBody().
3168 * @return string|NULL string the message body boundary.
3169 * or NULL if this message body has no boundary.
3171 function getBoundary() {}
3173 * Retrieve the underlying stream resource.
3175 * @return resource the underlying stream.
3177 function getResource() {}
3179 * Implements Serializable.
3180 * Alias of http\Message\Body::__toString().
3182 * @return string serialized message body.
3184 function serialize() {}
3186 * Stat size, atime, mtime and/or ctime.
3188 * @param string $field A single stat field to retrieve.
3189 * @return int|object int the requested stat field.
3190 * or object stdClass instance holding all four stat fields.
3192 function stat(string $field = NULL) {}
3194 * Stream the message body through a callback.
3196 * @param callable $callback The callback of the form function(http\Message\Body $from, string $data).
3197 * @param int $offset Start to stream from this offset.
3198 * @param int $maxlen Stream at most $maxlen bytes, or all if $maxlen is less than 1.
3199 * @return \http\Message\Body self.
3201 function toCallback(callable
$callback, int $offset = 0, int $maxlen = 0) {}
3203 * Stream the message body into another stream $stream, starting from $offset, streaming $maxlen at most.
3205 * @param resource $stream The resource to write to.
3206 * @param int $offset The starting offset.
3207 * @param int $maxlen The maximum amount of data to stream. All content if less than 1.
3208 * @return \http\Message\Body self.
3210 function toStream($stream, int $offset = 0, int $maxlen = 0) {}
3212 * Retrieve the message body serialized to a string.
3213 * Alias of http\Message\Body::__toString().
3215 * @return string message body.
3217 function toString() {}
3219 * Implements Serializable.
3221 * @param string $serialized The serialized message body.
3223 function unserialize($serialized) {}
3226 * The parser which is underlying http\Message.
3229 * > This class was added in v2.2.0.
3233 * Finish up parser at end of (incomplete) input.
3237 * Soak up the rest of input if no entity length is deducible.
3239 const DUMB_BODIES
= 2;
3241 * Redirect messages do not contain any body despite of indication of such.
3243 const EMPTY_REDIRECTS
= 4;
3245 * Continue parsing while input is available.
3251 const STATE_FAILURE
= -1;
3253 * Expecting HTTP info (request/response line) or headers.
3255 const STATE_START
= 0;
3259 const STATE_HEADER
= 1;
3261 * Completed parsing headers.
3263 const STATE_HEADER_DONE
= 2;
3267 const STATE_BODY
= 3;
3269 * Soaking up all input as body.
3271 const STATE_BODY_DUMB
= 4;
3273 * Reading body as indicated by `Content-Length` or `Content-Range`.
3275 const STATE_BODY_LENGTH
= 5;
3277 * Parsing `chunked` encoded body.
3279 const STATE_BODY_CHUNKED
= 6;
3281 * Finished parsing the body.
3283 const STATE_BODY_DONE
= 7;
3285 * Updating Content-Length based on body size.
3287 const STATE_UPDATE_CL
= 8;
3289 * Finished parsing the message.
3292 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
3294 const STATE_DONE
= 9;
3296 * Retrieve the current state of the parser.
3297 * See http\Message\Parser::STATE_* constants.
3299 * @throws \http\Exception\InvalidArgumentException
3300 * @return int http\Message\Parser::STATE_* constant.
3302 function getState() {}
3306 * @param string $data The (part of the) message to parse.
3307 * @param int $flags Any combination of [parser flags](http/Message/Parser#Parser.flags:).
3308 * @param \http\Message $message The current state of the message parsed.
3309 * @throws \http\Exception\InvalidArgumentException
3310 * @return int http\Message\Parser::STATE_* constant.
3312 function parse(string $data, int $flags, \http\Message
&$message) {}
3316 * @param resource $stream The message stream to parse from.
3317 * @param int $flags Any combination of [parser flags](http/Message/Parser#Parser.flags:).
3318 * @param \http\Message $message The current state of the message parsed.
3319 * @throws \http\Exception\InvalidArgumentException
3320 * @throws \http\Exception\UnexpectedValueException
3321 * @return int http\Message\Parser::STATE_* constant.
3323 function stream($stream, int $flags, \http\Message
&$message) {}