update live stub
[mdref/mdref-http] / http.stub.php
1 <?php
2 /**
3 * Extended HTTP support. Again.
4 *
5 * * Introduces the http namespace.
6 * * PHP stream based message bodies.
7 * * Encapsulated env request/response.
8 * * Modular client support.
9 */
10 namespace http;
11 use http;
12 /**
13 * The HTTP client. See http\Client\Curl's [options](http/Client/Curl#Options:) which is the only driver currently supported.
14 */
15 class Client implements \SplSubject, \Countable {
16 /**
17 * Debug callback's $data contains human readable text.
18 */
19 const DEBUG_INFO = 0;
20 /**
21 * Debug callback's $data contains data received.
22 */
23 const DEBUG_IN = 1;
24 /**
25 * Debug callback's $data contains data sent.
26 */
27 const DEBUG_OUT = 2;
28 /**
29 * Debug callback's $data contains headers.
30 */
31 const DEBUG_HEADER = 16;
32 /**
33 * Debug callback's $data contains a body part.
34 */
35 const DEBUG_BODY = 32;
36 /**
37 * Debug callback's $data contains SSL data.
38 */
39 const DEBUG_SSL = 64;
40 /**
41 * Attached observers.
42 *
43 * @private
44 * @var \SplObjectStorage
45 */
46 private $observers = NULL;
47 /**
48 * Set options.
49 *
50 * @protected
51 * @var array
52 */
53 protected $options = NULL;
54 /**
55 * Request/response history.
56 *
57 * @protected
58 * @var \http\Message
59 */
60 protected $history = NULL;
61 /**
62 * Whether to record history in http\Client::$history.
63 *
64 * @public
65 * @var bool
66 */
67 public $recordHistory = false;
68 /**
69 * Create a new HTTP client.
70 *
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.
73 *
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
79 */
80 function __construct(string $driver = NULL, string $persistent_handle_id = NULL) {}
81 /**
82 * Add custom cookies.
83 * See http\Client::setCookies().
84 *
85 * @param array $cookies Custom cookies to add.
86 * @throws \http\Exception\InvalidArgumentException
87 * @return \http\Client self.
88 */
89 function addCookies(array $cookies = NULL) {}
90 /**
91 * Add specific SSL options.
92 * See http\Client::setSslOptions(), http\Client::setOptions() and http\Client\Curl\$ssl options.
93 *
94 * @param array $ssl_options Add this SSL options.
95 * @throws \http\Exception\InvalidArgumentException
96 * @return \http\Client self.
97 */
98 function addSslOptions(array $ssl_options = NULL) {}
99 /**
100 * Implements SplSubject. Attach another observer.
101 * Attached observers will be notified with progress of each transfer.
102 *
103 * @param \SplObserver $observer An implementation of SplObserver.
104 * @throws \http\Exception\InvalidArgumentException
105 * @throws \http\Exception\UnexpectedValueException
106 * @return \http\Client self.
107 */
108 function attach(\SplObserver $observer) {}
109 /**
110 * Configure the client's low level options.
111 *
112 * > ***NOTE:***
113 * > This method has been added in v2.3.0.
114 *
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.
120 */
121 function configure(array $configuration) {}
122 /**
123 * Implements Countable. Retrieve the number of enqueued requests.
124 *
125 * > ***NOTE:***
126 * > The enqueued requests are counted without regard whether they are finished or not.
127 *
128 * @return int number of enqueued requests.
129 */
130 function count() {}
131 /**
132 * Dequeue the http\Client\Request $request.
133 *
134 * See http\Client::requeue(), if you want to requeue the request, instead of calling http\Client::dequeue() and then http\Client::enqueue().
135 *
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.
141 */
142 function dequeue(\http\Client\Request $request) {}
143 /**
144 * Implements SplSubject. Detach $observer, which has been previously attached.
145 *
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.
150 */
151 function detach(\SplObserver $observer) {}
152 /**
153 * Enable usage of an event library like libevent, which might improve performance with big socket sets.
154 *
155 * > ***NOTE:***
156 * > This method has been deprecated in 2.3.0, please use http\Client::configure() instead.
157 *
158 * @param bool $enable Whether to enable libevent usage.
159 * @throws \http\Exception\InvalidArgumentException
160 * @throws \http\Exception\UnexpectedValueException
161 * @return \http\Client self.
162 * @deprecated
163 */
164 function enableEvents(bool $enable = true) {}
165 /**
166 * Enable sending pipelined requests to the same host if the driver supports it.
167 *
168 * > ***NOTE:***
169 * > This method has been deprecated in 2.3.0, please use http\Client::configure() instead.
170 *
171 * @param bool $enable Whether to enable pipelining.
172 * @throws \http\Exception\InvalidArgumentException
173 * @throws \http\Exception\UnexpectedValueException
174 * @return \http\Client self.
175 * @deprecated
176 */
177 function enablePipelining(bool $enable = true) {}
178 /**
179 * Add another http\Client\Request to the request queue.
180 * If the optional callback $cb returns true, the request will be automatically dequeued.
181 *
182 * > ***Note:***
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.
185 * >
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.
189 *
190 * See http\Client::dequeue() and http\Client::send().
191 *
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.
199 */
200 function enqueue(\http\Client\Request $request, callable $cb = NULL) {}
201 /**
202 * Get a list of available configuration options and their default values.
203 *
204 * See f.e. the [configuration options for the Curl driver](http/Client/Curl#Configuration:).
205 *
206 * @throws \http\Exception\InvalidArgumentException
207 * @return array list of key/value pairs of available configuration options and their default values.
208 */
209 function getAvailableConfiguration() {}
210 /**
211 * List available drivers.
212 *
213 * @return array list of supported drivers.
214 */
215 function getAvailableDrivers() {}
216 /**
217 * Retrieve a list of available request options and their default values.
218 *
219 * See f.e. the [request options for the Curl driver](http/Client/Curl#Options:).
220 *
221 * @throws \http\Exception\InvalidArgumentException
222 * @return array list of key/value pairs of available request options and their default values.
223 */
224 function getAvailableOptions() {}
225 /**
226 * Get priorly set custom cookies.
227 * See http\Client::setCookies().
228 *
229 * @return array custom cookies.
230 */
231 function getCookies() {}
232 /**
233 * Simply returns the http\Message chain representing the request/response history.
234 *
235 * > ***NOTE:***
236 * > The history is only recorded while http\Client::$recordHistory is true.
237 *
238 * @throws \http\Exception\InvalidArgumentException
239 * @return \http\Message the request/response message chain representing the client's history.
240 */
241 function getHistory() {}
242 /**
243 * Returns the SplObjectStorage holding attached observers.
244 *
245 * @throws \http\Exception\InvalidArgumentException
246 * @throws \http\Exception\UnexpectedValueException
247 * @return \SplObjectStorage observer storage.
248 */
249 function getObservers() {}
250 /**
251 * Get priorly set options.
252 * See http\Client::setOptions().
253 *
254 * @return array options.
255 */
256 function getOptions() {}
257 /**
258 * Retrieve the progress information for $request.
259 *
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.
265 */
266 function getProgressInfo(\http\Client\Request $request) {}
267 /**
268 * Retrieve the corresponding response of an already finished request, or the last received response if $request is not set.
269 *
270 * > ***NOTE:***
271 * > If $request is NULL, then the response is removed from the internal storage (stack-like operation).
272 *
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.
278 */
279 function getResponse(\http\Client\Request $request = NULL) {}
280 /**
281 * Retrieve priorly set SSL options.
282 * See http\Client::getOptions() and http\Client::setSslOptions().
283 *
284 * @return array SSL options.
285 */
286 function getSslOptions() {}
287 /**
288 * Get transfer related information for a running or finished request.
289 *
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.
294 */
295 function getTransferInfo(\http\Client\Request $request) {}
296 /**
297 * Implements SplSubject. Notify attached observers about progress with $request.
298 *
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.
304 */
305 function notify(\http\Client\Request $request = NULL, $progress = NULL) {}
306 /**
307 * Perform outstanding transfer actions.
308 * See http\Client::wait() for the completing interface.
309 *
310 * @return bool true if there are more transfers to complete.
311 */
312 function once() {}
313 /**
314 * Requeue an http\Client\Request.
315 *
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.
317 *
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.
324 */
325 function requeue(\http\Client\Request $request, callable $cb = NULL) {}
326 /**
327 * Reset the client to the initial state.
328 *
329 * @return \http\Client self.
330 */
331 function reset() {}
332 /**
333 * Send all enqueued requests.
334 * See http\Client::once() and http\Client::wait() for a more fine grained interface.
335 *
336 * @throws \http\Exception\InvalidArgumentException
337 * @throws \http\Exception\RuntimeException
338 * @return \http\Client self.
339 */
340 function send() {}
341 /**
342 * Set custom cookies.
343 * See http\Client::addCookies() and http\Client::getCookies().
344 *
345 * @param array $cookies Set the custom cookies to this array.
346 * @throws \http\Exception\InvalidArgumentException
347 * @return \http\Client self.
348 */
349 function setCookies(array $cookies = NULL) {}
350 /**
351 * Set client debugging callback.
352 *
353 * > ***NOTE:***
354 * > This method has been added in v2.6.0, resp. v3.1.0.
355 *
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.
360 */
361 function setDebug(callable $callback) {}
362 /**
363 * Set client options.
364 * See http\Client\Curl.
365 *
366 * > ***NOTE:***
367 * > Only options specified prior enqueueing a request are applied to the request.
368 *
369 * @param array $options The options to set.
370 * @throws \http\Exception\InvalidArgumentException
371 * @return \http\Client self.
372 */
373 function setOptions(array $options = NULL) {}
374 /**
375 * Specifically set SSL options.
376 * See http\Client::setOptions() and http\Client\Curl\$ssl options.
377 *
378 * @param array $ssl_options Set SSL options to this array.
379 * @throws \http\Exception\InvalidArgumentException
380 * @return \http\Client self.
381 */
382 function setSslOptions(array $ssl_options = NULL) {}
383 /**
384 * Wait for $timeout seconds for transfers to provide data.
385 * This is the completion call to http\Client::once().
386 *
387 * @param float $timeout Seconds to wait for data on open sockets.
388 * @return bool success.
389 */
390 function wait(float $timeout = 0) {}
391 }
392 /**
393 * A class representing a list of cookies with specific attributes.
394 */
395 class Cookie {
396 /**
397 * Do not decode cookie contents.
398 */
399 const PARSE_RAW = 1;
400 /**
401 * The cookies' flags have the secure attribute set.
402 */
403 const SECURE = 16;
404 /**
405 * The cookies' flags have the httpOnly attribute set.
406 */
407 const HTTPONLY = 32;
408 /**
409 * Create a new cookie list.
410 *
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
416 */
417 function __construct($cookies = NULL, int $flags = 0, array $allowed_extras = NULL) {}
418 /**
419 * String cast handler. Alias of http\Cookie::toString().
420 *
421 * @return string the cookie(s) represented as string.
422 */
423 function __toString() {}
424 /**
425 * Add a cookie.
426 * See http\Cookie::setCookie() and http\Cookie::addCookies().
427 *
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.
432 */
433 function addCookie(string $cookie_name, string $cookie_value) {}
434 /**
435 * (Re)set the cookies.
436 * See http\Cookie::setCookies().
437 *
438 * @param array $cookies Add cookies of this array of form ["name" => "value"].
439 * @throws \http\Exception\InvalidArgumentException
440 * @return \http\Cookie self.
441 */
442 function addCookies(array $cookies) {}
443 /**
444 * Add an extra attribute to the cookie list.
445 * See http\Cookie::setExtra().
446 *
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.
451 */
452 function addExtra(string $extra_name, string $extra_value) {}
453 /**
454 * Add several extra attributes.
455 * See http\Cookie::addExtra().
456 *
457 * @param array $extras A list of extra attributes of the form ["key" => "value"].
458 * @throws \http\Exception\InvalidArgumentException
459 * @return \http\Cookie self.
460 */
461 function addExtras(array $extras) {}
462 /**
463 * Retrieve a specific cookie value.
464 * See http\Cookie::setCookie().
465 *
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.
469 */
470 function getCookie(string $cookie_name) {}
471 /**
472 * Get the list of cookies.
473 * See http\Cookie::setCookies().
474 *
475 * @return array the list of cookies of form ["name" => "value"].
476 */
477 function getCookies() {}
478 /**
479 * Retrieve the effective domain of the cookie list.
480 * See http\Cookie::setDomain().
481 *
482 * @return string the effective domain.
483 */
484 function getDomain() {}
485 /**
486 * Get the currently set expires attribute.
487 * See http\Cookie::setExpires().
488 *
489 * > ***NOTE:***
490 * > A return value of -1 means that the attribute is not set.
491 *
492 * @return int the currently set expires attribute as seconds since the epoch.
493 */
494 function getExpires() {}
495 /**
496 * Retrieve an extra attribute.
497 * See http\Cookie::setExtra().
498 *
499 * @param string $name The key of the extra attribute.
500 * @return string the value of the extra attribute.
501 */
502 function getExtra(string $name) {}
503 /**
504 * Retrieve the list of extra attributes.
505 * See http\Cookie::setExtras().
506 *
507 * @return array the list of extra attributes of the form ["key" => "value"].
508 */
509 function getExtras() {}
510 /**
511 * Get the currently set flags.
512 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
513 *
514 * @return int the currently set flags bitmask.
515 */
516 function getFlags() {}
517 /**
518 * Get the currently set max-age attribute of the cookie list.
519 * See http\Cookie::setMaxAge().
520 *
521 * > ***NOTE:***
522 * > A return value of -1 means that the attribute is not set.
523 *
524 * @return int the currently set max-age.
525 */
526 function getMaxAge() {}
527 /**
528 * Retrieve the path the cookie(s) of this cookie list are effective at.
529 * See http\Cookie::setPath().
530 *
531 * @return string the effective path.
532 */
533 function getPath() {}
534 /**
535 * (Re)set a cookie.
536 * See http\Cookie::addCookie() and http\Cookie::setCookies().
537 *
538 * > ***NOTE:***
539 * > The cookie will be deleted from the list if $cookie_value is NULL.
540 *
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.
545 */
546 function setCookie(string $cookie_name, string $cookie_value) {}
547 /**
548 * (Re)set the cookies.
549 * See http\Cookie::addCookies().
550 *
551 * @param array $cookies Set the cookies to this array.
552 * @throws \http\Exception\InvalidArgumentException
553 * @return \http\Cookie self.
554 */
555 function setCookies(array $cookies = NULL) {}
556 /**
557 * Set the effective domain of the cookie list.
558 * See http\Cookie::setPath().
559 *
560 * @param string $value The domain the cookie(s) belong to.
561 * @throws \http\Exception\InvalidArgumentException
562 * @return \http\Cookie self.
563 */
564 function setDomain(string $value = NULL) {}
565 /**
566 * Set the traditional expires timestamp.
567 * See http\Cookie::setMaxAge() for a safer alternative.
568 *
569 * @param int $value The expires timestamp as seconds since the epoch.
570 * @throws \http\Exception\InvalidArgumentException
571 * @return \http\Cookie self.
572 */
573 function setExpires(int $value = -1) {}
574 /**
575 * (Re)set an extra attribute.
576 * See http\Cookie::addExtra().
577 *
578 * > ***NOTE:***
579 * > The attribute will be removed from the extras list if $extra_value is NULL.
580 *
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.
585 */
586 function setExtra(string $extra_name, string $extra_value = NULL) {}
587 /**
588 * (Re)set the extra attributes.
589 * See http\Cookie::addExtras().
590 *
591 * @param array $extras Set the extra attributes to this array.
592 * @throws \http\Exception\InvalidArgumentException
593 * @return \http\Cookie self.
594 */
595 function setExtras(array $extras = NULL) {}
596 /**
597 * Set the flags to specified $value.
598 * See http\Cookie::SECURE and http\Cookie::HTTPONLY constants.
599 *
600 * @param int $value The new flags bitmask.
601 * @throws \http\Exception\InvalidArgumentException
602 * @return \http\Cookie self.
603 */
604 function setFlags(int $value = 0) {}
605 /**
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().
609 *
610 * @param int $value The max-age in seconds.
611 * @throws \http\Exception\InvalidArgumentException
612 * @return \http\Cookie self.
613 */
614 function setMaxAge(int $value = -1) {}
615 /**
616 * Set the path the cookie(s) of this cookie list should be effective at.
617 * See http\Cookie::setDomain().
618 *
619 * @param string $path The URL path the cookie(s) should take effect within.
620 * @throws \http\Exception\InvalidArgumentException
621 * @return \http\Cookie self.
622 */
623 function setPath(string $path = NULL) {}
624 /**
625 * Get the cookie list as array.
626 *
627 * @return array the cookie list as array.
628 */
629 function toArray() {}
630 /**
631 * Retrieve the string representation of the cookie list.
632 * See http\Cookie::toArray().
633 *
634 * @return string the cookie list as string.
635 */
636 function toString() {}
637 }
638 /**
639 *
640 */
641 namespace http\Encoding;
642 namespace http;
643 /**
644 * The http\Env class provides static methods to manipulate and inspect the server's current request's HTTP environment.
645 */
646 class Env {
647 /**
648 * Retrieve the current HTTP request's body.
649 *
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
654 */
655 function getRequestBody(string $body_class_name = NULL) {}
656 /**
657 * Retrieve one or all headers of the current HTTP request.
658 *
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
663 */
664 function getRequestHeader(string $header_name = NULL) {}
665 /**
666 * Get the HTTP response code to send.
667 *
668 * @return int the HTTP response code.
669 */
670 function getResponseCode() {}
671 /**
672 * Get one or all HTTP response headers to be sent.
673 *
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
678 */
679 function getResponseHeader(string $header_name = NULL) {}
680 /**
681 * Retrieve a list of all known HTTP response status.
682 *
683 * @return array mapping of the form \[
684 * ...
685 * int $code => string $status
686 * ...
687 * \]
688 */
689 function getResponseStatusForAllCodes() {}
690 /**
691 * Retrieve the string representation of specified HTTP response code.
692 *
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)
695 */
696 function getResponseStatusForCode(int $code) {}
697 /**
698 * Generic negotiator. For specific client negotiation see http\Env::negotiateContentType() and related methods.
699 *
700 * > ***NOTE:***
701 * > The first element of $supported serves as a default if no operand matches.
702 *
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).
709 */
710 function negotiate(string $params, array $supported, string $prim_typ_sep = NULL, array &$result = NULL) {}
711 /**
712 * Negotiate the client's preferred character set.
713 *
714 * > ***NOTE:***
715 * > The first element of $supported character sets serves as a default if no character set matches.
716 *
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.
721 */
722 function negotiateCharset(array $supported, array &$result = NULL) {}
723 /**
724 * Negotiate the client's preferred MIME content type.
725 *
726 * > ***NOTE:***
727 * > The first element of $supported content types serves as a default if no content-type matches.
728 *
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.
733 */
734 function negotiateContentType(array $supported, array &$result = NULL) {}
735 /**
736 * Negotiate the client's preferred encoding.
737 *
738 * > ***NOTE:***
739 * > The first element of $supported encodings serves as a default if no encoding matches.
740 *
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.
745 */
746 function negotiateEncoding(array $supported, array &$result = NULL) {}
747 /**
748 * Negotiate the client's preferred language.
749 *
750 * > ***NOTE:***
751 * > The first element of $supported languages serves as a default if no language matches.
752 *
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.
757 */
758 function negotiateLanguage(array $supported, array &$result = NULL) {}
759 /**
760 * Set the HTTP response code to send.
761 *
762 * @param int $code The HTTP response status code.
763 * @return bool Success.
764 */
765 function setResponseCode(int $code) {}
766 /**
767 * Set a response header, either replacing a prior set header, or appending the new header value, depending on $replace.
768 *
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.
770 *
771 * If $response_code is not 0, the response status code is updated accordingly.
772 *
773 * @param string $header_name
774 * @param mixed $header_value
775 * @param int $response_code
776 * @param bool $replace
777 * @return bool Success.
778 */
779 function setResponseHeader(string $header_name, $header_value = NULL, int $response_code = NULL, bool $replace = NULL) {}
780 }
781 /**
782 * The http extension's Exception interface.
783 *
784 * Use it to catch any Exception thrown by pecl/http.
785 *
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.
787 */
788 interface Exception {
789 }
790 /**
791 * The http\Header class provides methods to manipulate, match, negotiate and serialize HTTP headers.
792 */
793 class Header implements \Serializable {
794 /**
795 * None of the following match constraints applies.
796 */
797 const MATCH_LOOSE = 0;
798 /**
799 * Perform case sensitive matching.
800 */
801 const MATCH_CASE = 1;
802 /**
803 * Match only on word boundaries (according by CType alpha-numeric).
804 */
805 const MATCH_WORD = 16;
806 /**
807 * Match the complete string.
808 */
809 const MATCH_FULL = 32;
810 /**
811 * Case sensitively match the full string (same as MATCH_CASE|MATCH_FULL).
812 */
813 const MATCH_STRICT = 33;
814 /**
815 * The name of the HTTP header.
816 *
817 * @public
818 * @var string
819 */
820 public $name = NULL;
821 /**
822 * The value of the HTTP header.
823 *
824 * @public
825 * @var mixed
826 */
827 public $value = NULL;
828 /**
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.
830 *
831 * @param string $name The HTTP header name.
832 * @param mixed $value The value of the header.
833 *
834 * # Throws:
835 */
836 function __construct(string $name = NULL, $value = NULL) {}
837 /**
838 * String cast handler. Alias of http\Header::serialize().
839 *
840 * @return string the serialized form of the HTTP header (i.e. "Name: value").
841 */
842 function __toString() {}
843 /**
844 * Create a parameter list out of the HTTP header value.
845 *
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
851 */
852 function getParams($ps = NULL, $as = NULL, $vs = NULL, int $flags = NULL) {}
853 /**
854 * Match the HTTP header's value against provided $value according to $flags.
855 *
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.
859 */
860 function match(string $value, int $flags = NULL) {}
861 /**
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
866 * used instead.
867 *
868 * > ***NOTE:***
869 * > The first element of $supported serves as a default if no operand matches.
870 *
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).
875 */
876 function negotiate(array $supported, array &$result = NULL) {}
877 /**
878 * Parse HTTP headers.
879 * See also http\Header\Parser.
880 *
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.
885 */
886 function parse(string $header, string $header_class = NULL) {}
887 /**
888 * Implements Serializable.
889 *
890 * @return string serialized representation of HTTP header (i.e. "Name: value")
891 */
892 function serialize() {}
893 /**
894 * Convenience method. Alias of http\Header::serialize().
895 *
896 * @return string the serialized form of the HTTP header (i.e. "Name: value").
897 */
898 function toString() {}
899 /**
900 * Implements Serializable.
901 *
902 * @param string $serialized The serialized HTTP header (i.e. "Name: value")
903 */
904 function unserialize($serialized) {}
905 }
906 /**
907 * The message class builds the foundation for any request and response message.
908 *
909 * See http\Client\Request and http\Client\Response, as well as http\Env\Request and http\Env\Response.
910 */
911 class Message implements \Countable, \Serializable, \Iterator {
912 /**
913 * No specific type of message.
914 */
915 const TYPE_NONE = 0;
916 /**
917 * A request message.
918 */
919 const TYPE_REQUEST = 1;
920 /**
921 * A response message.
922 */
923 const TYPE_RESPONSE = 2;
924 /**
925 * The message type. See http\Message::TYPE_* constants.
926 *
927 * @protected
928 * @var int
929 */
930 protected $type = \http\Message::TYPE_NONE;
931 /**
932 * The message's body.
933 *
934 * @protected
935 * @var \http\Message\Body
936 */
937 protected $body = NULL;
938 /**
939 * The request method if the message is of type request.
940 *
941 * @protected
942 * @var string
943 */
944 protected $requestMethod = "";
945 /**
946 * The request url if the message is of type request.
947 *
948 * @protected
949 * @var string
950 */
951 protected $requestUrl = "";
952 /**
953 * The response status phrase if the message is of type response.
954 *
955 * @protected
956 * @var string
957 */
958 protected $responseStatus = "";
959 /**
960 * The response code if the message is of type response.
961 *
962 * @protected
963 * @var int
964 */
965 protected $responseCode = 0;
966 /**
967 * A custom HTTP protocol version.
968 *
969 * @protected
970 * @var string
971 */
972 protected $httpVersion = NULL;
973 /**
974 * Any message headers.
975 *
976 * @protected
977 * @var array
978 */
979 protected $headers = NULL;
980 /**
981 * Any parent message.
982 *
983 * @protected
984 * @var \http\Message
985 */
986 protected $parentMessage;
987 /**
988 * Create a new HTTP message.
989 *
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
994 */
995 function __construct($message = NULL, bool $greedy = true) {}
996 /**
997 * Retrieve the message serialized to a string.
998 * Alias of http\Message::toString().
999 *
1000 * @return string the single serialized HTTP message.
1001 */
1002 function __toString() {}
1003 /**
1004 * Append the data of $body to the message's body.
1005 * See http\Message::setBody() and http\Message\Body::append().
1006 *
1007 * @param \http\Message\Body $body The message body to add.
1008 * @return \http\Message self.
1009 */
1010 function addBody(\http\Message\Body $body) {}
1011 /**
1012 * Add an header, appending to already existing headers.
1013 * See http\Message::addHeaders() and http\Message::setHeader().
1014 *
1015 * @param string $name The header name.
1016 * @param mixed $value The header value.
1017 * @return \http\Message self.
1018 */
1019 function addHeader(string $name, $value) {}
1020 /**
1021 * Add headers, optionally appending values, if header keys already exist.
1022 * See http\Message::addHeader() and http\Message::setHeaders().
1023 *
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.
1027 */
1028 function addHeaders(array $headers, bool $append = false) {}
1029 /**
1030 * Implements Countable.
1031 *
1032 * @return int the count of messages in the chain above the current message.
1033 */
1034 function count() {}
1035 /**
1036 * Implements iterator.
1037 * See http\Message::valid() and http\Message::rewind().
1038 *
1039 * @return \http\Message the current message in the iterated message chain.
1040 */
1041 function current() {}
1042 /**
1043 * Detach a clone of this message from any message chain.
1044 *
1045 * @throws \http\Exception\InvalidArgumentException
1046 * @return \http\Message clone.
1047 */
1048 function detach() {}
1049 /**
1050 * Retrieve the message's body.
1051 * See http\Message::setBody().
1052 *
1053 * @throws \http\Exception\InvalidArgumentException
1054 * @throws \http\Exception\UnexpectedValueException
1055 * @return \http\Message\Body the message body.
1056 */
1057 function getBody() {}
1058 /**
1059 * Retrieve a single header, optionally hydrated into a http\Header extending class.
1060 *
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.
1065 */
1066 function getHeader(string $header, string $into_class = NULL) {}
1067 /**
1068 * Retrieve all message headers.
1069 * See http\Message::setHeaders() and http\Message::getHeader().
1070 *
1071 * @return array the message's headers.
1072 */
1073 function getHeaders() {}
1074 /**
1075 * Retrieve the HTTP protocol version of the message.
1076 * See http\Message::setHttpVersion().
1077 *
1078 * @return string the HTTP protocol version, e.g. "1.0"; defaults to "1.1".
1079 */
1080 function getHttpVersion() {}
1081 /**
1082 * Retrieve the first line of a request or response message.
1083 * See http\Message::setInfo and also:
1084 *
1085 * * http\Message::getType()
1086 * * http\Message::getHttpVersion()
1087 * * http\Message::getResponseCode()
1088 * * http\Message::getResponseStatus()
1089 * * http\Message::getRequestMethod()
1090 * * http\Message::getRequestUrl()
1091 *
1092 * @return string|NULL string the HTTP message information.
1093 * or NULL if the message is neither of type request nor response.
1094 */
1095 function getInfo() {}
1096 /**
1097 * Retrieve any parent message.
1098 * See http\Message::reverse().
1099 *
1100 * @throws \http\Exception\InvalidArgumentException
1101 * @throws \http\Exception\BadMethodCallException
1102 * @return \http\Message the parent message.
1103 */
1104 function getParentMessage() {}
1105 /**
1106 * Retrieve the request method of the message.
1107 * See http\Message::setRequestMethod() and http\Message::getRequestUrl().
1108 *
1109 * @return string|false string the request method.
1110 * or false if the message was not of type request.
1111 */
1112 function getRequestMethod() {}
1113 /**
1114 * Retrieve the request URL of the message.
1115 * See http\Message::setRequestUrl().
1116 *
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.
1119 */
1120 function getRequestUrl() {}
1121 /**
1122 * Retrieve the response code of the message.
1123 * See http\Message::setResponseCode() and http\Message::getResponseStatus().
1124 *
1125 * @return int|false int the response status code.
1126 * or false if the message is not of type response.
1127 */
1128 function getResponseCode() {}
1129 /**
1130 * Retrieve the response status of the message.
1131 * See http\Message::setResponseStatus() and http\Message::getResponseCode().
1132 *
1133 * @return string|false string the response status phrase.
1134 * or false if the message is not of type response.
1135 */
1136 function getResponseStatus() {}
1137 /**
1138 * Retrieve the type of the message.
1139 * See http\Message::setType() and http\Message::getInfo().
1140 *
1141 * @return int the message type. See http\Message::TYPE_* constants.
1142 */
1143 function getType() {}
1144 /**
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.
1147 *
1148 * See http\Message::splitMultipartBody().
1149 *
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".
1152 */
1153 function isMultipart(string &$boundary = NULL) {}
1154 /**
1155 * Implements Iterator.
1156 * See http\Message::current() and http\Message::rewind().
1157 *
1158 * @return int a non-sequential integer key.
1159 */
1160 function key() {}
1161 /**
1162 * Implements Iterator.
1163 * See http\Message::valid() and http\Message::rewind().
1164 */
1165 function next() {}
1166 /**
1167 * Prepend message(s) $message to this message, or the top most message of this message chain.
1168 *
1169 * > ***NOTE:***
1170 * > The message chains must not overlap.
1171 *
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.
1177 */
1178 function prepend(\http\Message $message, bool $top = true) {}
1179 /**
1180 * Reverse the message chain and return the former top-most message.
1181 *
1182 * > ***NOTE:***
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.
1184 * >
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.
1186 *
1187 * @throws \http\Exception\InvalidArgumentException
1188 * @return \http\Message the other end of the message chain.
1189 */
1190 function reverse() {}
1191 /**
1192 * Implements Iterator.
1193 */
1194 function rewind() {}
1195 /**
1196 * Implements Serializable.
1197 *
1198 * @return string the serialized HTTP message.
1199 */
1200 function serialize() {}
1201 /**
1202 * Set the message's body.
1203 * See http\Message::getBody() and http\Message::addBody().
1204 *
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.
1209 */
1210 function setBody(\http\Message\Body $body) {}
1211 /**
1212 * Set a single header.
1213 * See http\Message::getHeader() and http\Message::addHeader().
1214 *
1215 * > ***NOTE:***
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.
1218 *
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.
1222 */
1223 function setHeader(string $header, $value = NULL) {}
1224 /**
1225 * Set the message headers.
1226 * See http\Message::getHeaders() and http\Message::addHeaders().
1227 *
1228 * > ***NOTE:***
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.
1231 *
1232 * @param array $headers The message's headers.
1233 * @return \http\Message null.
1234 */
1235 function setHeaders(array $headers = NULL) {}
1236 /**
1237 * Set the HTTP protocol version of the message.
1238 * See http\Message::getHttpVersion().
1239 *
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.
1244 */
1245 function setHttpVersion(string $http_version) {}
1246 /**
1247 * Set the complete message info, i.e. type and response resp. request information, at once.
1248 * See http\Message::getInfo().
1249 *
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.
1254 */
1255 function setInfo(string $http_info) {}
1256 /**
1257 * Set the request method of the message.
1258 * See http\Message::getRequestMethod() and http\Message::setRequestUrl().
1259 *
1260 * @param string $method The request method.
1261 * @throws \http\Exception\InvalidArgumentException
1262 * @throws \http\Exception\BadMethodCallException
1263 * @return \http\Message self.
1264 */
1265 function setRequestMethod(string $method) {}
1266 /**
1267 * Set the request URL of the message.
1268 * See http\Message::getRequestUrl() and http\Message::setRequestMethod().
1269 *
1270 * @param string $url The request URL.
1271 * @throws \http\Exception\InvalidArgumentException
1272 * @throws \http\Exception\BadMethodCallException
1273 * @return \http\Message self.
1274 */
1275 function setRequestUrl(string $url) {}
1276 /**
1277 * Set the response status code.
1278 * See http\Message::getResponseCode() and http\Message::setResponseStatus().
1279 *
1280 * > ***NOTE:***
1281 * > This method also resets the response status phrase to the default for that code.
1282 *
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.
1288 */
1289 function setResponseCode(int $response_code, bool $strict = true) {}
1290 /**
1291 * Set the response status phrase.
1292 * See http\Message::getResponseStatus() and http\Message::setResponseCode().
1293 *
1294 * @param string $response_status The status phrase.
1295 * @throws \http\Exception\InvalidArgumentException
1296 * @throws \http\Exception\BadMethodCallException
1297 * @return \http\Message self.
1298 */
1299 function setResponseStatus(string $response_status) {}
1300 /**
1301 * Set the message type and reset the message info.
1302 * See http\Message::getType() and http\Message::setInfo().
1303 *
1304 * @param int $type The desired message type. See the http\Message::TYPE_* constants.
1305 * @return \http\Message self.
1306 */
1307 function setType(int $type) {}
1308 /**
1309 * Splits the body of a multipart message.
1310 * See http\Message::isMultipart() and http\Message\Body::addPart().
1311 *
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.
1316 */
1317 function splitMultipartBody() {}
1318 /**
1319 * Stream the message through a callback.
1320 *
1321 * @param callable $callback The callback of the form function(http\Message $from, string $data).
1322 * @return \http\Message self.
1323 */
1324 function toCallback(callable $callback) {}
1325 /**
1326 * Stream the message into stream $stream, starting from $offset, streaming $maxlen at most.
1327 *
1328 * @param resource $stream The resource to write to.
1329 * @return \http\Message self.
1330 */
1331 function toStream($stream) {}
1332 /**
1333 * Retrieve the message serialized to a string.
1334 *
1335 * @param bool $include_parent Whether to include all parent messages.
1336 * @return string the HTTP message chain serialized to a string.
1337 */
1338 function toString(bool $include_parent = false) {}
1339 /**
1340 * Implements Serializable.
1341 *
1342 * @param string $data The serialized message.
1343 */
1344 function unserialize($data) {}
1345 /**
1346 * Implements Iterator.
1347 * See http\Message::current() and http\Message::rewind().
1348 *
1349 * @return bool whether http\Message::current() would not return NULL.
1350 */
1351 function valid() {}
1352 }
1353 /**
1354 * Parse, interpret and compose HTTP (header) parameters.
1355 */
1356 class Params implements \ArrayAccess {
1357 /**
1358 * The default parameter separator (",").
1359 */
1360 const DEF_PARAM_SEP = ',';
1361 /**
1362 * The default argument separator (";").
1363 */
1364 const DEF_ARG_SEP = ';';
1365 /**
1366 * The default value separator ("=").
1367 */
1368 const DEF_VAL_SEP = '=';
1369 /**
1370 * Empty param separator to parse cookies.
1371 */
1372 const COOKIE_PARAM_SEP = '';
1373 /**
1374 * Do not interpret the parsed parameters.
1375 */
1376 const PARSE_RAW = 0;
1377 /**
1378 * Interpret input as default formatted parameters.
1379 */
1380 const PARSE_DEFAULT = 17;
1381 /**
1382 * Parse backslash escaped (quoted) strings.
1383 */
1384 const PARSE_ESCAPED = 1;
1385 /**
1386 * Urldecode single units of parameters, arguments and values.
1387 */
1388 const PARSE_URLENCODED = 4;
1389 /**
1390 * Parse sub dimensions indicated by square brackets.
1391 */
1392 const PARSE_DIMENSION = 8;
1393 /**
1394 * Parse URL querystring (same as http\Params::PARSE_URLENCODED|http\Params::PARSE_DIMENSION).
1395 */
1396 const PARSE_QUERY = 12;
1397 /**
1398 * Parse [RFC5987](http://tools.ietf.org/html/rfc5987) style encoded character set and language information embedded in HTTP header params.
1399 */
1400 const PARSE_RFC5987 = 16;
1401 /**
1402 * Parse [RFC5988](http://tools.ietf.org/html/rfc5988) (Web Linking) tags of Link headers.
1403 */
1404 const PARSE_RFC5988 = 32;
1405 /**
1406 * The (parsed) parameters.
1407 *
1408 * @public
1409 * @var array
1410 */
1411 public $params = NULL;
1412 /**
1413 * The parameter separator(s).
1414 *
1415 * @public
1416 * @var array
1417 */
1418 public $param_sep = \http\Params::DEF_PARAM_SEP;
1419 /**
1420 * The argument separator(s).
1421 *
1422 * @public
1423 * @var array
1424 */
1425 public $arg_sep = \http\Params::DEF_ARG_SEP;
1426 /**
1427 * The value separator(s).
1428 *
1429 * @public
1430 * @var array
1431 */
1432 public $val_sep = \http\Params::DEF_VAL_SEP;
1433 /**
1434 * The modus operandi of the parser. See http\Params::PARSE_* constants.
1435 *
1436 * @public
1437 * @var int
1438 */
1439 public $flags = \http\Params::PARSE_DEFAULT;
1440 /**
1441 * Instantiate a new HTTP (header) parameter set.
1442 *
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
1450 */
1451 function __construct($params = NULL, $ps = NULL, $as = NULL, $vs = NULL, int $flags = NULL) {}
1452 /**
1453 * String cast handler. Alias of http\Params::toString().
1454 * Returns a stringified version of the parameters.
1455 *
1456 * @return string version of the parameters.
1457 */
1458 function __toString() {}
1459 /**
1460 * Implements ArrayAccess.
1461 *
1462 * @param string $name The offset to look after.
1463 * @return bool Existence.
1464 */
1465 function offsetExists($name) {}
1466 /**
1467 * Implements ArrayAccess.
1468 *
1469 * @param string $name The offset to retrieve.
1470 * @return mixed contents at offset.
1471 */
1472 function offsetGet($name) {}
1473 /**
1474 * Implements ArrayAccess.
1475 *
1476 * @param string $name The offset to modify.
1477 * @param mixed $value The value to set.
1478 */
1479 function offsetSet($name, $value) {}
1480 /**
1481 * Implements ArrayAccess.
1482 *
1483 * @param string $name The offset to delete.
1484 */
1485 function offsetUnset($name) {}
1486 /**
1487 * Convenience method that simply returns http\Params::$params.
1488 *
1489 * @return array of parameters.
1490 */
1491 function toArray() {}
1492 /**
1493 * Returns a stringified version of the parameters.
1494 *
1495 * @return string version of the parameters.
1496 */
1497 function toString() {}
1498 }
1499 /**
1500 * The http\QueryString class provides versatile facilities to retrieve, use and manipulate query strings and form data.
1501 */
1502 class QueryString implements \Serializable, \ArrayAccess, \IteratorAggregate {
1503 /**
1504 * Cast requested value to bool.
1505 */
1506 const TYPE_BOOL = 16;
1507 /**
1508 * Cast requested value to int.
1509 */
1510 const TYPE_INT = 4;
1511 /**
1512 * Cast requested value to float.
1513 */
1514 const TYPE_FLOAT = 5;
1515 /**
1516 * Cast requested value to string.
1517 */
1518 const TYPE_STRING = 6;
1519 /**
1520 * Cast requested value to an array.
1521 */
1522 const TYPE_ARRAY = 7;
1523 /**
1524 * Cast requested value to an object.
1525 */
1526 const TYPE_OBJECT = 8;
1527 /**
1528 * The global instance. See http\QueryString::getGlobalInstance().
1529 *
1530 * @private
1531 * @var \http\QueryString
1532 */
1533 private $instance = NULL;
1534 /**
1535 * The data.
1536 *
1537 * @private
1538 * @var array
1539 */
1540 private $queryArray = NULL;
1541 /**
1542 * Create an independent querystring instance.
1543 *
1544 * @param mixed $params The query parameters to use or parse.
1545 * @throws \http\Exception\BadQueryStringException
1546 */
1547 function __construct($params = NULL) {}
1548 /**
1549 * Get the string representation of the querystring (x-www-form-urlencoded).
1550 *
1551 * @return string the x-www-form-urlencoded querystring.
1552 */
1553 function __toString() {}
1554 /**
1555 * Retrieve an querystring value.
1556 *
1557 * See http\QueryString::TYPE_* constants.
1558 *
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.
1568 */
1569 function get(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
1570 /**
1571 * Retrieve an array value with at offset $name.
1572 *
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.
1578 */
1579 function getArray(string $name, $defval = NULL, bool $delete = false) {}
1580 /**
1581 * Retrieve a boolean value at offset $name.
1582 *
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.
1588 */
1589 function getBool(string $name, $defval = NULL, bool $delete = false) {}
1590 /**
1591 * Retrieve a float value at offset $name.
1592 *
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.
1598 */
1599 function getFloat(string $name, $defval = NULL, bool $delete = false) {}
1600 /**
1601 * Retrieve the global querystring instance referencing $_GET.
1602 *
1603 * @throws \http\Exception\UnexpectedValueException
1604 * @return \http\QueryString the http\QueryString::$instance
1605 */
1606 function getGlobalInstance() {}
1607 /**
1608 * Retrieve a int value at offset $name.
1609 *
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.
1615 */
1616 function getInt(string $name, $defval = NULL, bool $delete = false) {}
1617 /**
1618 * Implements IteratorAggregate.
1619 *
1620 * @throws \http\Exception\InvalidArgumentException
1621 * @throws \InvalidArgumentException
1622 */
1623 function getIterator() {}
1624 /**
1625 * Retrieve a object value with at offset $name.
1626 *
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.
1632 */
1633 function getObject(string $name, $defval = NULL, bool $delete = false) {}
1634 /**
1635 * Retrieve a string value with at offset $name.
1636 *
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.
1642 */
1643 function getString(string $name, $defval = NULL, bool $delete = false) {}
1644 /**
1645 * Set additional $params to a clone of this instance.
1646 * See http\QueryString::set().
1647 *
1648 * > ***NOTE:***
1649 * > This method returns a clone (copy) of this instance.
1650 *
1651 * @param mixed $params Additional params as object, array or string to parse.
1652 * @throws \http\Exception\BadQueryStringException
1653 * @return \http\QueryString clone.
1654 */
1655 function mod($params = NULL) {}
1656 /**
1657 * Implements ArrayAccess.
1658 *
1659 * @param string $name The offset to look up.
1660 * @return bool whether the key $name isset.
1661 */
1662 function offsetExists($name) {}
1663 /**
1664 * Implements ArrayAccess.
1665 *
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.
1669 */
1670 function offsetGet($offset) {}
1671 /**
1672 * Implements ArrayAccess.
1673 *
1674 * @param string $name The key to set the value for.
1675 * @param mixed $data The data to place at offset $name.
1676 */
1677 function offsetSet($name, $data) {}
1678 /**
1679 * Implements ArrayAccess.
1680 *
1681 * @param string $name The offset to look up.
1682 */
1683 function offsetUnset($name) {}
1684 /**
1685 * Implements Serializable.
1686 * See http\QueryString::toString().
1687 *
1688 * @return string the x-www-form-urlencoded querystring.
1689 */
1690 function serialize() {}
1691 /**
1692 * Set additional querystring entries.
1693 *
1694 * @param mixed $params Additional params as object, array or string to parse.
1695 * @return \http\QueryString self.
1696 */
1697 function set($params) {}
1698 /**
1699 * Simply returns http\QueryString::$queryArray.
1700 *
1701 * @return array the $queryArray property.
1702 */
1703 function toArray() {}
1704 /**
1705 * Get the string representation of the querystring (x-www-form-urlencoded).
1706 *
1707 * @return string the x-www-form-urlencoded querystring.
1708 */
1709 function toString() {}
1710 /**
1711 * Implements Serializable.
1712 *
1713 * @param string $serialized The x-www-form-urlencoded querystring.
1714 * @throws \http\Exception
1715 */
1716 function unserialize($serialized) {}
1717 /**
1718 * Translate character encodings of the querystring with ext/iconv.
1719 *
1720 * > ***NOTE:***
1721 * > This method is only available when ext/iconv support was enabled at build time.
1722 *
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.
1728 */
1729 function xlate(string $from_enc, string $to_enc) {}
1730 }
1731 /**
1732 * The http\Url class provides versatile means to parse, construct and manipulate URLs.
1733 */
1734 class Url {
1735 /**
1736 * Replace parts of the old URL with parts of the new.
1737 */
1738 const REPLACE = 0;
1739 /**
1740 * Whether a relative path should be joined into the old path.
1741 */
1742 const JOIN_PATH = 1;
1743 /**
1744 * Whether the querystrings should be joined.
1745 */
1746 const JOIN_QUERY = 2;
1747 /**
1748 * Strip the user information from the URL.
1749 */
1750 const STRIP_USER = 4;
1751 /**
1752 * Strip the password from the URL.
1753 */
1754 const STRIP_PASS = 8;
1755 /**
1756 * Strip user and password information from URL (same as STRIP_USER|STRIP_PASS).
1757 */
1758 const STRIP_AUTH = 12;
1759 /**
1760 * Do not include the port.
1761 */
1762 const STRIP_PORT = 32;
1763 /**
1764 * Do not include the URL path.
1765 */
1766 const STRIP_PATH = 64;
1767 /**
1768 * Do not include the URL querystring.
1769 */
1770 const STRIP_QUERY = 128;
1771 /**
1772 * Strip the fragment (hash) from the URL.
1773 */
1774 const STRIP_FRAGMENT = 256;
1775 /**
1776 * Strip everything except scheme and host information.
1777 */
1778 const STRIP_ALL = 492;
1779 /**
1780 * Import initial URL parts from the SAPI environment.
1781 */
1782 const FROM_ENV = 4096;
1783 /**
1784 * Whether to sanitize the URL path (consolidate double slashes, directory jumps etc.)
1785 */
1786 const SANITIZE_PATH = 8192;
1787 /**
1788 * Parse UTF-8 encoded multibyte sequences.
1789 */
1790 const PARSE_MBUTF8 = 131072;
1791 /**
1792 * Parse locale encoded multibyte sequences (on systems with wide character support).
1793 */
1794 const PARSE_MBLOC = 65536;
1795 /**
1796 * Parse and convert multibyte hostnames according to IDNA (with IDNA support).
1797 */
1798 const PARSE_TOIDN = 1048576;
1799 /**
1800 * Explicitly request IDNA2003 implementation if available (libidn, idnkit or ICU).
1801 */
1802 const PARSE_TOIDN_2003 = 9437184;
1803 /**
1804 * Explicitly request IDNA2008 implementation if available (libidn2, idnkit2 or ICU).
1805 */
1806 const PARSE_TOIDN_2008 = 5242880;
1807 /**
1808 * Percent encode multibyte sequences in the userinfo, path, query and fragment parts of the URL.
1809 */
1810 const PARSE_TOPCT = 2097152;
1811 /**
1812 * Continue parsing when encountering errors.
1813 */
1814 const IGNORE_ERRORS = 268435456;
1815 /**
1816 * Suppress errors/exceptions.
1817 */
1818 const SILENT_ERRORS = 536870912;
1819 /**
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.
1822 */
1823 const STDFLAGS = 3350531;
1824 /**
1825 * The URL's scheme.
1826 *
1827 * @public
1828 * @var string
1829 */
1830 public $scheme = NULL;
1831 /**
1832 * Authenticating user.
1833 *
1834 * @public
1835 * @var string
1836 */
1837 public $user = NULL;
1838 /**
1839 * Authentication password.
1840 *
1841 * @public
1842 * @var string
1843 */
1844 public $pass = NULL;
1845 /**
1846 * Hostname/domain.
1847 *
1848 * @public
1849 * @var string
1850 */
1851 public $host = NULL;
1852 /**
1853 * Port.
1854 *
1855 * @public
1856 * @var string
1857 */
1858 public $port = NULL;
1859 /**
1860 * URL path.
1861 *
1862 * @public
1863 * @var string
1864 */
1865 public $path = NULL;
1866 /**
1867 * URL querystring.
1868 *
1869 * @public
1870 * @var string
1871 */
1872 public $query = NULL;
1873 /**
1874 * URL fragment (hash).
1875 *
1876 * @public
1877 * @var string
1878 */
1879 public $fragment = NULL;
1880 /**
1881 * Create an instance of an http\Url.
1882 *
1883 * > ***NOTE:***
1884 * > Prior to v3.0.0, the default for the $flags parameter was http\Url::FROM_ENV.
1885 *
1886 * See also http\Env\Url.
1887 *
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
1893 */
1894 function __construct($old_url = NULL, $new_url = NULL, int $flags = 0) {}
1895 /**
1896 * String cast handler. Alias of http\Url::toString().
1897 *
1898 * @return string the URL as string.
1899 */
1900 function __toString() {}
1901 /**
1902 * Clone this URL and apply $parts to the cloned URL.
1903 *
1904 * > ***NOTE:***
1905 * > This method returns a clone (copy) of this instance.
1906 *
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.
1912 */
1913 function mod($parts, int $flags = \http\Url::JOIN_PATH|http\Url::JOIN_QUERY|http\Url::SANITIZE_PATH) {}
1914 /**
1915 * Retrieve the URL parts as array.
1916 *
1917 * @return array the URL parts.
1918 */
1919 function toArray() {}
1920 /**
1921 * Get the string prepresentation of the URL.
1922 *
1923 * @return string the URL as string.
1924 */
1925 function toString() {}
1926 }
1927 /**
1928 * The http\Client\Curl namespace holds option value constants specific to the curl driver of the http\Client.
1929 */
1930 namespace http\Client\Curl;
1931 /**
1932 * Bitmask of available libcurl features.
1933 * See http\Client\Curl\Features namespace.
1934 */
1935 const FEATURES = 4179869;
1936 /**
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.
1940 */
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';
1942 /**
1943 * Use HTTP/1.0 protocol version.
1944 */
1945 const HTTP_VERSION_1_0 = 1;
1946 /**
1947 * Use HTTP/1.1 protocol version.
1948 */
1949 const HTTP_VERSION_1_1 = 2;
1950 /**
1951 * Attempt to use HTTP/2 protocol version. Available if libcurl is v7.33.0 or more recent and was built with nghttp2 support.
1952 */
1953 const HTTP_VERSION_2_0 = 3;
1954 /**
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.
1956 */
1957 const HTTP_VERSION_2TLS = 4;
1958 /**
1959 * Use any HTTP protocol version.
1960 */
1961 const HTTP_VERSION_ANY = 0;
1962 /**
1963 * Use TLS v1.0 encryption.
1964 */
1965 const SSL_VERSION_TLSv1_0 = 4;
1966 /**
1967 * Use TLS v1.1 encryption.
1968 */
1969 const SSL_VERSION_TLSv1_1 = 5;
1970 /**
1971 * Use TLS v1.2 encryption.
1972 */
1973 const SSL_VERSION_TLSv1_2 = 6;
1974 /**
1975 * Use any TLS v1 encryption.
1976 */
1977 const SSL_VERSION_TLSv1 = 1;
1978 /**
1979 * Use SSL v2 encryption.
1980 */
1981 const SSL_VERSION_SSLv2 = 2;
1982 /**
1983 * Use SSL v3 encryption.
1984 */
1985 const SSL_VERSION_SSLv3 = 3;
1986 /**
1987 * Use any encryption.
1988 */
1989 const SSL_VERSION_ANY = 0;
1990 /**
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.
1992 */
1993 const TLSAUTH_SRP = 1;
1994 /**
1995 * Use IPv4 resolver.
1996 */
1997 const IPRESOLVE_V4 = 1;
1998 /**
1999 * Use IPv6 resolver.
2000 */
2001 const IPRESOLVE_V6 = 2;
2002 /**
2003 * Use any resolver.
2004 */
2005 const IPRESOLVE_ANY = 0;
2006 /**
2007 * Use Basic authentication.
2008 */
2009 const AUTH_BASIC = 1;
2010 /**
2011 * Use Digest authentication.
2012 */
2013 const AUTH_DIGEST = 2;
2014 /**
2015 * Use IE (lower v7) quirks with Digest authentication. Available if libcurl is v7.19.3 or more recent.
2016 */
2017 const AUTH_DIGEST_IE = 16;
2018 /**
2019 * Use NTLM authentication.
2020 */
2021 const AUTH_NTLM = 8;
2022 /**
2023 * Use GSS-Negotiate authentication.
2024 */
2025 const AUTH_GSSNEG = 4;
2026 /**
2027 * Use HTTP Netgotiate authentication (SPNEGO, RFC4559). Available if libcurl is v7.38.0 or more recent.
2028 */
2029 const AUTH_SPNEGO = 4;
2030 /**
2031 * Use any authentication.
2032 */
2033 const AUTH_ANY = -17;
2034 /**
2035 * Use SOCKSv4 proxy protocol.
2036 */
2037 const PROXY_SOCKS4 = 4;
2038 /**
2039 * Use SOCKSv4a proxy protocol.
2040 */
2041 const PROXY_SOCKS4A = 5;
2042 /**
2043 * Use SOCKS5h proxy protocol.
2044 */
2045 const PROXY_SOCKS5_HOSTNAME = 5;
2046 /**
2047 * Use SOCKS5 proxy protoccol.
2048 */
2049 const PROXY_SOCKS5 = 5;
2050 /**
2051 * Use HTTP/1.1 proxy protocol.
2052 */
2053 const PROXY_HTTP = 0;
2054 /**
2055 * Use HTTP/1.0 proxy protocol. Available if libcurl is v7.19.4 or more recent.
2056 */
2057 const PROXY_HTTP_1_0 = 1;
2058 /**
2059 * Keep POSTing on 301 redirects. Available if libcurl is v7.19.1 or more recent.
2060 */
2061 const POSTREDIR_301 = 1;
2062 /**
2063 * Keep POSTing on 302 redirects. Available if libcurl is v7.19.1 or more recent.
2064 */
2065 const POSTREDIR_302 = 2;
2066 /**
2067 * Keep POSTing on 303 redirects. Available if libcurl is v7.19.1 or more recent.
2068 */
2069 const POSTREDIR_303 = 4;
2070 /**
2071 * Keep POSTing on any redirect. Available if libcurl is v7.19.1 or more recent.
2072 */
2073 const POSTREDIR_ALL = 7;
2074 namespace http\Client;
2075 /**
2076 * The http\Client\Request class provides an HTTP message implementation tailored to represent a request message to be sent by the client.
2077 *
2078 * See http\Client::enqueue().
2079 */
2080 class Request extends \http\Message {
2081 /**
2082 * Array of options for this request, which override client options.
2083 *
2084 * @protected
2085 * @var array
2086 */
2087 protected $options = NULL;
2088 /**
2089 * Create a new client request message to be enqueued and sent by http\Client.
2090 *
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
2097 */
2098 function __construct(string $meth = NULL, string $url = NULL, array $headers = NULL, \http\Message\Body $body = NULL) {}
2099 /**
2100 * Add querystring data.
2101 * See http\Client\Request::setQuery() and http\Message::setRequestUrl().
2102 *
2103 * @param mixed $query_data Additional querystring data.
2104 * @throws \http\Exception\InvalidArgumentException
2105 * @throws \http\Exception\BadQueryStringException
2106 * @return \http\Client\Request self.
2107 */
2108 function addQuery($query_data) {}
2109 /**
2110 * Add specific SSL options.
2111 * See http\Client\Request::setSslOptions(), http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2112 *
2113 * @param array $ssl_options Add this SSL options.
2114 * @throws \http\Exception\InvalidArgumentException
2115 * @return \http\Client\Request self.
2116 */
2117 function addSslOptions(array $ssl_options = NULL) {}
2118 /**
2119 * Extract the currently set "Content-Type" header.
2120 * See http\Client\Request::setContentType().
2121 *
2122 * @return string|NULL string the currently set content type.
2123 * or NULL if no "Content-Type" header is set.
2124 */
2125 function getContentType() {}
2126 /**
2127 * Get priorly set options.
2128 * See http\Client\Request::setOptions().
2129 *
2130 * @return array options.
2131 */
2132 function getOptions() {}
2133 /**
2134 * Retrieve the currently set querystring.
2135 *
2136 * @return string|NULL string the currently set querystring.
2137 * or NULL if no querystring is set.
2138 */
2139 function getQuery() {}
2140 /**
2141 * Retrieve priorly set SSL options.
2142 * See http\Client\Request::getOptions() and http\Client\Request::setSslOptions().
2143 *
2144 * @return array SSL options.
2145 */
2146 function getSslOptions() {}
2147 /**
2148 * Set the MIME content type of the request message.
2149 *
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.
2154 */
2155 function setContentType(string $content_type) {}
2156 /**
2157 * Set client options.
2158 * See http\Client::setOptions() and http\Client\Curl.
2159 *
2160 * Request specific options override general options which were set in the client.
2161 *
2162 * > ***NOTE:***
2163 * > Only options specified prior enqueueing a request are applied to the request.
2164 *
2165 * @param array $options The options to set.
2166 * @throws \http\Exception\InvalidArgumentException
2167 * @return \http\Client\Request self.
2168 */
2169 function setOptions(array $options = NULL) {}
2170 /**
2171 * (Re)set the querystring.
2172 * See http\Client\Request::addQuery() and http\Message::setRequestUrl().
2173 *
2174 * @param mixed $query_data
2175 * @throws \http\Exception\InvalidArgumentException
2176 * @throws \http\Exception\BadQueryStringException
2177 * @return \http\Client\Request self.
2178 */
2179 function setQuery($query_data) {}
2180 /**
2181 * Specifically set SSL options.
2182 * See http\Client\Request::setOptions() and http\Client\Curl\$ssl options.
2183 *
2184 * @param array $ssl_options Set SSL options to this array.
2185 * @throws \http\Exception\InvalidArgumentException
2186 * @return \http\Client\Request self.
2187 */
2188 function setSslOptions(array $ssl_options = NULL) {}
2189 }
2190 /**
2191 * The http\Client\Response class represents an HTTP message the client returns as answer from a server to an http\Client\Request.
2192 */
2193 class Response extends \http\Message {
2194 /**
2195 * Extract response cookies.
2196 * Parses any "Set-Cookie" response headers into an http\Cookie list. See http\Cookie::__construct().
2197 *
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.
2201 */
2202 function getCookies(int $flags = 0, array $allowed_extras = NULL) {}
2203 /**
2204 * Retrieve transfer related information after the request has completed.
2205 * See http\Client::getTransferInfo().
2206 *
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.
2213 */
2214 function getTransferInfo(string $name = NULL) {}
2215 }
2216 namespace http\Client\Curl;
2217 /**
2218 * Interface to an user event loop implementation for http\Client::configure()'s $use_eventloop option.
2219 *
2220 * > ***NOTE:***
2221 * > This interface was added in v2.6.0, resp. v3.1.0.
2222 */
2223 interface User {
2224 /**
2225 * No action.
2226 */
2227 const POLL_NONE = 0;
2228 /**
2229 * Poll for read readiness.
2230 */
2231 const POLL_IN = 1;
2232 /**
2233 * Poll for write readiness.
2234 */
2235 const POLL_OUT = 2;
2236 /**
2237 * Poll for read/write readiness.
2238 */
2239 const POLL_INOUT = 3;
2240 /**
2241 * Stop polling for activity on this descriptor.
2242 */
2243 const POLL_REMOVE = 4;
2244 /**
2245 * Initialize the event loop.
2246 *
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.
2249 *
2250 *
2251 * > ***NOTE***:
2252 * > The callback should be run when a timeout occurs or a watched socket needs action.
2253 */
2254 function init(callable $run);
2255 /**
2256 * Run the loop as long as it does not block.
2257 *
2258 * > ***NOTE:***
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.
2260 */
2261 function once();
2262 /**
2263 * Run the loop.
2264 *
2265 * > ***NOTE:***
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.
2267 */
2268 function send();
2269 /**
2270 * Register (or deregister) a socket watcher.
2271 *
2272 * @param resource $socket The socket descriptor to watch.
2273 * @param int $poll http\Client\Curl\User::POLL_* constant.
2274 */
2275 function socket($socket, int $poll);
2276 /**
2277 * Register a timeout watcher.
2278 *
2279 * @param int $timeout_ms Desired maximum timeout in milliseconds.
2280 */
2281 function timer(int $timeout_ms);
2282 /**
2283 * Wait/poll/select (block the loop) until events fire.
2284 *
2285 * > ***NOTE:***
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.
2287 *
2288 * @param int $timeout_ms Block for at most this milliseconds.
2289 */
2290 function wait(int $timeout_ms = null);
2291 }
2292 /**
2293 * CURL feature constants.
2294 *
2295 * > ***NOTE:***
2296 * > These constants have been added in v2.6.0, resp. v3.1.0.
2297 */
2298 namespace http\Client\Curl\Features;
2299 /**
2300 * Whether libcurl supports asynchronous domain name resolution.
2301 */
2302 const ASYNCHDNS = 128;
2303 /**
2304 * Whether libcurl supports the Generic Security Services Application Program Interface. Available if libcurl is v7.38.0 or more recent.
2305 */
2306 const GSSAPI = 131072;
2307 /**
2308 * Whether libcurl supports HTTP Generic Security Services negotiation.
2309 */
2310 const GSSNEGOTIATE = 32;
2311 /**
2312 * Whether libcurl supports the HTTP/2 protocol. Available if libcurl is v7.33.0 or more recent.
2313 */
2314 const HTTP2 = 65536;
2315 /**
2316 * Whether libcurl supports international domain names.
2317 */
2318 const IDN = 1024;
2319 /**
2320 * Whether libcurl supports IPv6.
2321 */
2322 const IPV6 = 1;
2323 /**
2324 * Whether libcurl supports the old Kerberos protocol.
2325 */
2326 const KERBEROS4 = 2;
2327 /**
2328 * Whether libcurl supports the more recent Kerberos v5 protocol. Available if libcurl is v7.40.0 or more recent.
2329 */
2330 const KERBEROS5 = 262144;
2331 /**
2332 * Whether libcurl supports large files.
2333 */
2334 const LARGEFILE = 512;
2335 /**
2336 * Whether libcurl supports gzip/deflate compression.
2337 */
2338 const LIBZ = 8;
2339 /**
2340 * Whether libcurl supports the NT Lan Manager authentication.
2341 */
2342 const NTLM = 16;
2343 /**
2344 * Whether libcurl supports NTLM delegation to a winbind helper. Available if libcurl is v7.22.0 or more recent.
2345 */
2346 const NTLM_WB = 32768;
2347 /**
2348 * Whether libcurl supports the Public Suffix List for cookie host handling. Available if libcurl is v7.47.0 or more recent.
2349 */
2350 const PSL = 1048576;
2351 /**
2352 * Whether libcurl supports the Simple and Protected GSSAPI Negotiation Mechanism.
2353 */
2354 const SPNEGO = 256;
2355 /**
2356 * Whether libcurl supports SSL/TLS protocols.
2357 */
2358 const SSL = 4;
2359 /**
2360 * Whether libcurl supports the Security Support Provider Interface.
2361 */
2362 const SSPI = 2048;
2363 /**
2364 * Whether libcurl supports TLS Secure Remote Password authentication. Available if libcurl is v7.21.4 or more recent.
2365 */
2366 const TLSAUTH_SRP = 16384;
2367 /**
2368 * Whether libcurl supports connections to unix sockets. Available if libcurl is v7.40.0 or more recent.
2369 */
2370 const UNIX_SOCKETS = 524288;
2371 /**
2372 * CURL version constants.
2373 *
2374 * > ***NOTE:***
2375 * > These constants have been added in v2.6.0, resp. v3.1.0.
2376 */
2377 namespace http\Client\Curl\Versions;
2378 /**
2379 * Version string of libcurl, e.g. "7.50.0".
2380 */
2381 const CURL = '7.64.0';
2382 /**
2383 * Version string of the SSL/TLS library, e.g. "OpenSSL/1.0.2h".
2384 */
2385 const SSL = 'OpenSSL/1.1.1d';
2386 /**
2387 * Version string of the zlib compression library, e.g. "1.2.8".
2388 */
2389 const LIBZ = '1.2.11';
2390 /**
2391 * Version string of the c-ares library, e.g. "1.11.0".
2392 */
2393 const ARES = NULL;
2394 /**
2395 * Version string of the IDN library, e.g. "1.32".
2396 */
2397 const IDN = NULL;
2398 namespace http\Encoding;
2399 /**
2400 * Base class for encoding stream implementations.
2401 */
2402 abstract class Stream {
2403 /**
2404 * Do no intermittent flushes.
2405 */
2406 const FLUSH_NONE = 0;
2407 /**
2408 * Flush at appropriate transfer points.
2409 */
2410 const FLUSH_SYNC = 1048576;
2411 /**
2412 * Flush at each IO operation.
2413 */
2414 const FLUSH_FULL = 2097152;
2415 /**
2416 * Base constructor for encoding stream implementations.
2417 *
2418 * @param int $flags See http\Encoding\Stream and implementation specific constants.
2419 * @throws \http\Exception\InvalidArgumentException
2420 * @throws \http\Exception\RuntimeException
2421 */
2422 function __construct(int $flags = 0) {}
2423 /**
2424 * Check whether the encoding stream is already done.
2425 *
2426 * @return bool whether the encoding stream is completed.
2427 */
2428 function done() {}
2429 /**
2430 * Finish and reset the encoding stream.
2431 * Returns any pending data.
2432 *
2433 * @return string any pending data.
2434 */
2435 function finish() {}
2436 /**
2437 * Flush the encoding stream.
2438 * Returns any pending data.
2439 *
2440 * @return string any pending data.
2441 */
2442 function flush() {}
2443 /**
2444 * Update the encoding stream with more input.
2445 *
2446 * @param string $data The data to pass through the stream.
2447 * @return string processed data.
2448 */
2449 function update(string $data) {}
2450 }
2451 namespace http\Encoding\Stream;
2452 /**
2453 * A [brotli](https://brotli.org) decoding stream.
2454 *
2455 * > ***NOTE:***
2456 * > This class has been added in v3.2.0.
2457 */
2458 class Debrotli extends \http\Encoding\Stream {
2459 /**
2460 * Decode brotli encoded data.
2461 *
2462 * @param string $data The data to uncompress.
2463 * @return string the uncompressed data.
2464 */
2465 function decode(string $data) {}
2466 }
2467 /**
2468 * A stream decoding data encoded with chunked transfer encoding.
2469 */
2470 class Dechunk extends \http\Encoding\Stream {
2471 /**
2472 * Decode chunked encoded data.
2473 *
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.
2481 */
2482 function decode(string $data, int &$decoded_len = 0) {}
2483 }
2484 /**
2485 * A deflate stream supporting deflate, zlib and gzip encodings.
2486 */
2487 class Deflate extends \http\Encoding\Stream {
2488 /**
2489 * Gzip encoding. RFC1952
2490 */
2491 const TYPE_GZIP = 16;
2492 /**
2493 * Zlib encoding. RFC1950
2494 */
2495 const TYPE_ZLIB = 0;
2496 /**
2497 * Deflate encoding. RFC1951
2498 */
2499 const TYPE_RAW = 32;
2500 /**
2501 * Default compression level.
2502 */
2503 const LEVEL_DEF = 0;
2504 /**
2505 * Least compression level.
2506 */
2507 const LEVEL_MIN = 1;
2508 /**
2509 * Greatest compression level.
2510 */
2511 const LEVEL_MAX = 9;
2512 /**
2513 * Default compression strategy.
2514 */
2515 const STRATEGY_DEF = 0;
2516 /**
2517 * Filtered compression strategy.
2518 */
2519 const STRATEGY_FILT = 256;
2520 /**
2521 * Huffman strategy only.
2522 */
2523 const STRATEGY_HUFF = 512;
2524 /**
2525 * Run-length encoding strategy.
2526 */
2527 const STRATEGY_RLE = 768;
2528 /**
2529 * Encoding with fixed Huffman codes only.
2530 *
2531 * > **A note on the compression strategy:**
2532 * >
2533 * > The strategy parameter is used to tune the compression algorithm.
2534 * >
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).
2536 * >
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.
2538 * >
2539 * > RLE is designed to be almost as fast as HUFFMAN_ONLY, but give better compression for PNG image data.
2540 * >
2541 * > FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
2542 * >
2543 * > The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately.
2544 * >
2545 * >_Source: [zlib Manual](http://www.zlib.net/manual.html)_
2546 */
2547 const STRATEGY_FIXED = 1024;
2548 /**
2549 * Encode data with deflate/zlib/gzip encoding.
2550 *
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.
2554 */
2555 function encode(string $data, int $flags = 0) {}
2556 }
2557 /**
2558 * A [brotli](https://brotli.org) encoding stream.
2559 *
2560 * > ***NOTE:***
2561 * > This class has been added in v3.2.0.
2562 */
2563 class Enbrotli extends \http\Encoding\Stream {
2564 /**
2565 * Default compression level.
2566 */
2567 const LEVEL_DEF = NULL;
2568 /**
2569 * Least compression level.
2570 */
2571 const LEVEL_MIN = NULL;
2572 /**
2573 * Greatest compression level.
2574 */
2575 const LEVEL_MAX = NULL;
2576 /**
2577 * Default window bits.
2578 */
2579 const WBITS_DEF = NULL;
2580 /**
2581 * Minimum window bits.
2582 */
2583 const WBITS_MIN = NULL;
2584 /**
2585 * Maximum window bits.
2586 */
2587 const WBITS_MAX = NULL;
2588 /**
2589 * Default compression mode.
2590 */
2591 const MODE_GENERIC = NULL;
2592 /**
2593 * Compression mode for UTF-8 formatted text.
2594 */
2595 const MODE_TEXT = NULL;
2596 /**
2597 * Compression mode used in WOFF 2.0.
2598 */
2599 const MODE_FONT = NULL;
2600 /**
2601 * Encode data with brotli encoding.
2602 *
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.
2606 */
2607 function encode(string $data, int $flags = 0) {}
2608 }
2609 /**
2610 * A inflate stream supporting deflate, zlib and gzip encodings.
2611 */
2612 class Inflate extends \http\Encoding\Stream {
2613 /**
2614 * Decode deflate/zlib/gzip encoded data.
2615 *
2616 * @param string $data The data to uncompress.
2617 * @return string the uncompressed data.
2618 */
2619 function decode(string $data) {}
2620 }
2621 namespace http\Env;
2622 /**
2623 * The http\Env\Request class' instances represent the server's current HTTP request.
2624 *
2625 * See http\Message for inherited members.
2626 */
2627 class Request extends \http\Message {
2628 /**
2629 * The request's query parameters. ($_GET)
2630 *
2631 * @protected
2632 * @var \http\QueryString
2633 */
2634 protected $query = NULL;
2635 /**
2636 * The request's form parameters. ($_POST)
2637 *
2638 * @protected
2639 * @var \http\QueryString
2640 */
2641 protected $form = NULL;
2642 /**
2643 * The request's form uploads. ($_FILES)
2644 *
2645 * @protected
2646 * @var array
2647 */
2648 protected $files = NULL;
2649 /**
2650 * The request's cookies. ($_COOKIE)
2651 *
2652 * @protected
2653 * @var array
2654 */
2655 protected $cookie = NULL;
2656 /**
2657 * Create an instance of the server's current HTTP request.
2658 *
2659 * Upon construction, the http\Env\Request acquires http\QueryString instances of query parameters ($\_GET) and form parameters ($\_POST).
2660 *
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.
2662 *
2663 * @throws \http\Exception\InvalidArgumentException
2664 * @throws \http\Exception\UnexpectedValueException
2665 */
2666 function __construct() {}
2667 /**
2668 * Retrieve an URL query value ($_GET).
2669 *
2670 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2671 *
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.
2681 */
2682 function getCookie(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2683 /**
2684 * Retrieve the uploaded files list ($_FILES).
2685 *
2686 * @return array the consolidated upload files array.
2687 */
2688 function getFiles() {}
2689 /**
2690 * Retrieve a form value ($_POST).
2691 *
2692 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2693 *
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.
2703 */
2704 function getForm(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2705 /**
2706 * Retrieve an URL query value ($_GET).
2707 *
2708 * See http\QueryString::get() and http\QueryString::TYPE_* constants.
2709 *
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.
2719 */
2720 function getQuery(string $name = NULL, $type = NULL, $defval = NULL, bool $delete = false) {}
2721 }
2722 /**
2723 * The http\Env\Response class' instances represent the server's current HTTP response.
2724 *
2725 * See http\Message for inherited members.
2726 */
2727 class Response extends \http\Message {
2728 /**
2729 * Do not use content encoding.
2730 */
2731 const CONTENT_ENCODING_NONE = 0;
2732 /**
2733 * Support "Accept-Encoding" requests with gzip and deflate encoding.
2734 */
2735 const CONTENT_ENCODING_GZIP = 1;
2736 /**
2737 * No caching info available.
2738 */
2739 const CACHE_NO = 0;
2740 /**
2741 * The cache was hit.
2742 */
2743 const CACHE_HIT = 1;
2744 /**
2745 * The cache was missed.
2746 */
2747 const CACHE_MISS = 2;
2748 /**
2749 * A request instance which overrides the environments default request.
2750 *
2751 * @protected
2752 * @var \http\Env\Request
2753 */
2754 protected $request = NULL;
2755 /**
2756 * The response's MIME content type.
2757 *
2758 * @protected
2759 * @var string
2760 */
2761 protected $contentType = NULL;
2762 /**
2763 * The response's MIME content disposition.
2764 *
2765 * @protected
2766 * @var string
2767 */
2768 protected $contentDisposition = NULL;
2769 /**
2770 * See http\Env\Response::CONTENT_ENCODING_* constants.
2771 *
2772 * @protected
2773 * @var int
2774 */
2775 protected $contentEncoding = NULL;
2776 /**
2777 * How the client should treat this response in regards to caching.
2778 *
2779 * @protected
2780 * @var string
2781 */
2782 protected $cacheControl = NULL;
2783 /**
2784 * A custom ETag.
2785 *
2786 * @protected
2787 * @var string
2788 */
2789 protected $etag = NULL;
2790 /**
2791 * A "Last-Modified" time stamp.
2792 *
2793 * @protected
2794 * @var int
2795 */
2796 protected $lastModified = NULL;
2797 /**
2798 * Any throttling delay.
2799 *
2800 * @protected
2801 * @var int
2802 */
2803 protected $throttleDelay = NULL;
2804 /**
2805 * The chunk to send every $throttleDelay seconds.
2806 *
2807 * @protected
2808 * @var int
2809 */
2810 protected $throttleChunk = NULL;
2811 /**
2812 * The response's cookies.
2813 *
2814 * @protected
2815 * @var array
2816 */
2817 protected $cookies = NULL;
2818 /**
2819 * Create a new env response message instance.
2820 *
2821 * @throws \http\Exception\InvalidArgumentException
2822 * @throws \http\Exception\UnexpectedValueException
2823 */
2824 function __construct() {}
2825 /**
2826 * Output buffer handler.
2827 * Appends output data to the body.
2828 *
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.
2832 */
2833 function __invoke(string $data, int $ob_flags = 0) {}
2834 /**
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.
2837 *
2838 * @param string $header_name The request header to test.
2839 * @return int a http\Env\Response::CACHE_* constant.
2840 */
2841 function isCachedByEtag(string $header_name = "If-None-Match") {}
2842 /**
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.
2845 *
2846 * @param string $header_name The request header to test.
2847 * @return int a http\Env\Response::CACHE_* constant.
2848 */
2849 function isCachedByLastModified(string $header_name = "If-Modified-Since") {}
2850 /**
2851 * Send the response through the SAPI or $stream.
2852 * Flushes all output buffers.
2853 *
2854 * @param resource $stream A writable stream to send the response through.
2855 * @return bool success.
2856 */
2857 function send($stream = NULL) {}
2858 /**
2859 * Make suggestions to the client how it should cache the response.
2860 *
2861 * @param string $cache_control (A) "Cache-Control" header value(s).
2862 * @throws \http\Exception\InvalidArgumentException
2863 * @return \http\Env\Response self.
2864 */
2865 function setCacheControl(string $cache_control) {}
2866 /**
2867 * Set the reponse's content disposition parameters.
2868 *
2869 * @param array $disposition_params MIME content disposition as http\Params array.
2870 * @throws \http\Exception\InvalidArgumentException
2871 * @return \http\Env\Response self.
2872 */
2873 function setContentDisposition(array $disposition_params) {}
2874 /**
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.
2877 *
2878 * @param int $content_encoding See http\Env\Response::CONTENT_ENCODING_* constants.
2879 * @throws \http\Exception\InvalidArgumentException
2880 * @return \http\Env\Response self.
2881 */
2882 function setContentEncoding(int $content_encoding) {}
2883 /**
2884 * Set the MIME content type of the response.
2885 *
2886 * @param string $content_type The response's content type.
2887 * @throws \http\Exception\InvalidArgumentException
2888 * @return \http\Env\Response self.
2889 */
2890 function setContentType(string $content_type) {}
2891 /**
2892 * Add cookies to the response to send.
2893 *
2894 * @param mixed $cookie The cookie to send.
2895 * @throws \http\Exception\InvalidArgumentException
2896 * @throws \http\Exception\UnexpectedValueException
2897 * @return \http\Env\Response self.
2898 */
2899 function setCookie($cookie) {}
2900 /**
2901 * Override the environment's request.
2902 *
2903 * @param \http\Message $env_request The overriding request message.
2904 * @throws \http\Exception\InvalidArgumentException
2905 * @return \http\Env\Response self.
2906 */
2907 function setEnvRequest(\http\Message $env_request) {}
2908 /**
2909 * Set a custom ETag.
2910 *
2911 * > ***NOTE:***
2912 * > This will be used for caching and pre-condition checks.
2913 *
2914 * @param string $etag A ETag.
2915 * @throws \http\Exception\InvalidArgumentException
2916 * @return \http\Env\Response self.
2917 */
2918 function setEtag(string $etag) {}
2919 /**
2920 * Set a custom last modified time stamp.
2921 *
2922 * > ***NOTE:***
2923 * > This will be used for caching and pre-condition checks.
2924 *
2925 * @param int $last_modified A unix timestamp.
2926 * @throws \http\Exception\InvalidArgumentException
2927 * @return \http\Env\Response self.
2928 */
2929 function setLastModified(int $last_modified) {}
2930 /**
2931 * Enable throttling.
2932 * Send $chunk_size bytes every $delay seconds.
2933 *
2934 * > ***NOTE:***
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.
2936 *
2937 * @param int $chunk_size Bytes to send.
2938 * @param float $delay Seconds to sleep.
2939 * @return \http\Env\Response self.
2940 */
2941 function setThrottleRate(int $chunk_size, float $delay = 1) {}
2942 }
2943 /**
2944 * URL class using the HTTP environment by default.
2945 *
2946 * > ***NOTE:***
2947 * > This class has been added in v3.0.0.
2948 *
2949 * Always adds http\Url::FROM_ENV to the $flags constructor argument. See also http\Url.
2950 */
2951 class Url extends \http\Url {
2952 }
2953 namespace http\Exception;
2954 /**
2955 * A bad conversion (e.g. character conversion) was encountered.
2956 */
2957 class BadConversionException extends \DomainException implements \http\Exception {
2958 }
2959 /**
2960 * A bad HTTP header was encountered.
2961 */
2962 class BadHeaderException extends \DomainException implements \http\Exception {
2963 }
2964 /**
2965 * A bad HTTP message was encountered.
2966 */
2967 class BadMessageException extends \DomainException implements \http\Exception {
2968 }
2969 /**
2970 * A method was called on an object, which was in an invalid or unexpected state.
2971 */
2972 class BadMethodCallException extends \BadMethodCallException implements \http\Exception {
2973 }
2974 /**
2975 * A bad querystring was encountered.
2976 */
2977 class BadQueryStringException extends \DomainException implements \http\Exception {
2978 }
2979 /**
2980 * A bad HTTP URL was encountered.
2981 */
2982 class BadUrlException extends \DomainException implements \http\Exception {
2983 }
2984 /**
2985 * One or more invalid arguments were passed to a method.
2986 */
2987 class InvalidArgumentException extends \InvalidArgumentException implements \http\Exception {
2988 }
2989 /**
2990 * A generic runtime exception.
2991 */
2992 class RuntimeException extends \RuntimeException implements \http\Exception {
2993 }
2994 /**
2995 * An unexpected value was encountered.
2996 */
2997 class UnexpectedValueException extends \UnexpectedValueException implements \http\Exception {
2998 }
2999 namespace http\Header;
3000 /**
3001 * The parser which is underlying http\Header and http\Message.
3002 *
3003 * > ***NOTE:***
3004 * > This class has been added in v2.3.0.
3005 */
3006 class Parser {
3007 /**
3008 * Finish up parser at end of (incomplete) input.
3009 */
3010 const CLEANUP = 1;
3011 /**
3012 * Parse failure.
3013 */
3014 const STATE_FAILURE = -1;
3015 /**
3016 * Expecting HTTP info (request/response line) or headers.
3017 */
3018 const STATE_START = 0;
3019 /**
3020 * Expecting a key or already parsing a key.
3021 */
3022 const STATE_KEY = 1;
3023 /**
3024 * Expecting a value or already parsing the value.
3025 */
3026 const STATE_VALUE = 2;
3027 /**
3028 * At EOL of an header, checking whether a folded header line follows.
3029 */
3030 const STATE_VALUE_EX = 3;
3031 /**
3032 * A header was completed.
3033 */
3034 const STATE_HEADER_DONE = 4;
3035 /**
3036 * Finished parsing the headers.
3037 *
3038 * > ***NOTE:***
3039 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
3040 */
3041 const STATE_DONE = 5;
3042 /**
3043 * Retrieve the current state of the parser.
3044 * See http\Header\Parser::STATE_* constants.
3045 *
3046 * @throws \http\Exception\InvalidArgumentException
3047 * @return int http\Header\Parser::STATE_* constant.
3048 */
3049 function getState() {}
3050 /**
3051 * Parse a string.
3052 *
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.
3058 */
3059 function parse(string $data, int $flags, array &$header = NULL) {}
3060 /**
3061 * Parse a stream.
3062 *
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.
3069 */
3070 function stream($stream, int $flags, array &$headers) {}
3071 }
3072 namespace http\Message;
3073 /**
3074 * The message body, represented as a PHP (temporary) stream.
3075 *
3076 * > ***NOTE:***
3077 * > Currently, http\Message\Body::addForm() creates multipart/form-data bodies.
3078 */
3079 class Body implements \Serializable {
3080 /**
3081 * Create a new message body, optionally referencing $stream.
3082 *
3083 * @param resource $stream A stream to be used as message body.
3084 * @throws \http\Exception\InvalidArgumentException
3085 * @throws \http\Exception\UnexpectedValueException
3086 */
3087 function __construct($stream = NULL) {}
3088 /**
3089 * String cast handler.
3090 *
3091 * @return string the message body.
3092 */
3093 function __toString() {}
3094 /**
3095 * Add form fields and files to the message body.
3096 *
3097 * > ***NOTE:***
3098 * > Currently, http\Message\Body::addForm() creates "multipart/form-data" bodies.
3099 *
3100 * @param array $fields List of form fields to add.
3101 * @param array $files List of form files to add.
3102 *
3103 * $fields must look like:
3104 *
3105 * [
3106 * "field_name" => "value",
3107 * "multi_field" => [
3108 * "value1",
3109 * "value2"
3110 * ]
3111 * ]
3112 *
3113 * $files must look like:
3114 *
3115 * [
3116 * [
3117 * "name" => "field_name",
3118 * "type" => "content/type",
3119 * "file" => "/path/to/file.ext"
3120 * ], [
3121 * "name" => "field_name2",
3122 * "type" => "text/plain",
3123 * "file" => "file.ext",
3124 * "data" => "string"
3125 * ], [
3126 * "name" => "field_name3",
3127 * "type" => "image/jpeg",
3128 * "file" => "file.ext",
3129 * "data" => fopen("/home/mike/Pictures/mike.jpg","r")
3130 * ]
3131 *
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.
3136 */
3137 function addForm(array $fields = NULL, array $files = NULL) {}
3138 /**
3139 * Add a part to a multipart body.
3140 *
3141 * @param \http\Message $part The message part.
3142 * @throws \http\Exception\InvalidArgumentException
3143 * @throws \http\Exception\RuntimeException
3144 * @return \http\Message\Body self.
3145 */
3146 function addPart(\http\Message $part) {}
3147 /**
3148 * Append plain bytes to the message body.
3149 *
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.
3154 */
3155 function append(string $data) {}
3156 /**
3157 * Retrieve the ETag of the body.
3158 *
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.
3162 */
3163 function etag() {}
3164 /**
3165 * Retrieve any boundary of the message body.
3166 * See http\Message::splitMultipartBody().
3167 *
3168 * @return string|NULL string the message body boundary.
3169 * or NULL if this message body has no boundary.
3170 */
3171 function getBoundary() {}
3172 /**
3173 * Retrieve the underlying stream resource.
3174 *
3175 * @return resource the underlying stream.
3176 */
3177 function getResource() {}
3178 /**
3179 * Implements Serializable.
3180 * Alias of http\Message\Body::__toString().
3181 *
3182 * @return string serialized message body.
3183 */
3184 function serialize() {}
3185 /**
3186 * Stat size, atime, mtime and/or ctime.
3187 *
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.
3191 */
3192 function stat(string $field = NULL) {}
3193 /**
3194 * Stream the message body through a callback.
3195 *
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.
3200 */
3201 function toCallback(callable $callback, int $offset = 0, int $maxlen = 0) {}
3202 /**
3203 * Stream the message body into another stream $stream, starting from $offset, streaming $maxlen at most.
3204 *
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.
3209 */
3210 function toStream($stream, int $offset = 0, int $maxlen = 0) {}
3211 /**
3212 * Retrieve the message body serialized to a string.
3213 * Alias of http\Message\Body::__toString().
3214 *
3215 * @return string message body.
3216 */
3217 function toString() {}
3218 /**
3219 * Implements Serializable.
3220 *
3221 * @param string $serialized The serialized message body.
3222 */
3223 function unserialize($serialized) {}
3224 }
3225 /**
3226 * The parser which is underlying http\Message.
3227 *
3228 * > ***NOTE:***
3229 * > This class was added in v2.2.0.
3230 */
3231 class Parser {
3232 /**
3233 * Finish up parser at end of (incomplete) input.
3234 */
3235 const CLEANUP = 1;
3236 /**
3237 * Soak up the rest of input if no entity length is deducible.
3238 */
3239 const DUMB_BODIES = 2;
3240 /**
3241 * Redirect messages do not contain any body despite of indication of such.
3242 */
3243 const EMPTY_REDIRECTS = 4;
3244 /**
3245 * Continue parsing while input is available.
3246 */
3247 const GREEDY = 8;
3248 /**
3249 * Parse failure.
3250 */
3251 const STATE_FAILURE = -1;
3252 /**
3253 * Expecting HTTP info (request/response line) or headers.
3254 */
3255 const STATE_START = 0;
3256 /**
3257 * Parsing headers.
3258 */
3259 const STATE_HEADER = 1;
3260 /**
3261 * Completed parsing headers.
3262 */
3263 const STATE_HEADER_DONE = 2;
3264 /**
3265 * Parsing the body.
3266 */
3267 const STATE_BODY = 3;
3268 /**
3269 * Soaking up all input as body.
3270 */
3271 const STATE_BODY_DUMB = 4;
3272 /**
3273 * Reading body as indicated by `Content-Length` or `Content-Range`.
3274 */
3275 const STATE_BODY_LENGTH = 5;
3276 /**
3277 * Parsing `chunked` encoded body.
3278 */
3279 const STATE_BODY_CHUNKED = 6;
3280 /**
3281 * Finished parsing the body.
3282 */
3283 const STATE_BODY_DONE = 7;
3284 /**
3285 * Updating Content-Length based on body size.
3286 */
3287 const STATE_UPDATE_CL = 8;
3288 /**
3289 * Finished parsing the message.
3290 *
3291 * > ***NOTE:***
3292 * > Most of this states won't be returned to the user, because the parser immediately jumps to the next expected state.
3293 */
3294 const STATE_DONE = 9;
3295 /**
3296 * Retrieve the current state of the parser.
3297 * See http\Message\Parser::STATE_* constants.
3298 *
3299 * @throws \http\Exception\InvalidArgumentException
3300 * @return int http\Message\Parser::STATE_* constant.
3301 */
3302 function getState() {}
3303 /**
3304 * Parse a string.
3305 *
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.
3311 */
3312 function parse(string $data, int $flags, \http\Message &$message) {}
3313 /**
3314 * Parse a stream.
3315 *
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.
3322 */
3323 function stream($stream, int $flags, \http\Message &$message) {}
3324 }