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