PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / rmccue / requests / library / Requests / Response.php
ameliabooking / vendor / rmccue / requests / library / Requests Last commit date
Auth 4 years ago Cookie 2 years ago Exception 4 years ago Proxy 4 years ago Response 4 years ago Transport 2 years ago Utility 2 years ago Auth.php 4 years ago Cookie.php 4 years ago Exception.php 4 years ago Hooker.php 4 years ago Hooks.php 2 years ago IDNAEncoder.php 4 years ago IPv6.php 4 years ago IRI.php 2 years ago Proxy.php 4 years ago Response.php 4 years ago SSL.php 4 years ago Session.php 2 years ago Transport.php 4 years ago
Response.php
123 lines
1 <?php
2 /**
3 * HTTP response class
4 *
5 * Contains a response from Requests::request()
6 * @package Requests
7 */
8
9 /**
10 * HTTP response class
11 *
12 * Contains a response from Requests::request()
13 * @package Requests
14 */
15 class Requests_Response {
16 /**
17 * Constructor
18 */
19 public function __construct() {
20 $this->headers = new Requests_Response_Headers();
21 $this->cookies = new Requests_Cookie_Jar();
22 }
23
24 /**
25 * Response body
26 *
27 * @var string
28 */
29 public $body = '';
30
31 /**
32 * Raw HTTP data from the transport
33 *
34 * @var string
35 */
36 public $raw = '';
37
38 /**
39 * Headers, as an associative array
40 *
41 * @var Requests_Response_Headers Array-like object representing headers
42 */
43 public $headers = array();
44
45 /**
46 * Status code, false if non-blocking
47 *
48 * @var integer|boolean
49 */
50 public $status_code = false;
51
52 /**
53 * Protocol version, false if non-blocking
54 *
55 * @var float|boolean
56 */
57 public $protocol_version = false;
58
59 /**
60 * Whether the request succeeded or not
61 *
62 * @var boolean
63 */
64 public $success = false;
65
66 /**
67 * Number of redirects the request used
68 *
69 * @var integer
70 */
71 public $redirects = 0;
72
73 /**
74 * URL requested
75 *
76 * @var string
77 */
78 public $url = '';
79
80 /**
81 * Previous requests (from redirects)
82 *
83 * @var array Array of Requests_Response objects
84 */
85 public $history = array();
86
87 /**
88 * Cookies from the request
89 *
90 * @var Requests_Cookie_Jar Array-like object representing a cookie jar
91 */
92 public $cookies = array();
93
94 /**
95 * Is the response a redirect?
96 *
97 * @return boolean True if redirect (3xx status), false if not.
98 */
99 public function is_redirect() {
100 $code = $this->status_code;
101 return in_array($code, array(300, 301, 302, 303, 307), true) || $code > 307 && $code < 400;
102 }
103
104 /**
105 * Throws an exception if the request was not successful
106 *
107 * @throws Requests_Exception If `$allow_redirects` is false, and code is 3xx (`response.no_redirects`)
108 * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})
109 * @param boolean $allow_redirects Set to false to throw on a 3xx as well
110 */
111 public function throw_for_status($allow_redirects = true) {
112 if ($this->is_redirect()) {
113 if (!$allow_redirects) {
114 throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this);
115 }
116 }
117 elseif (!$this->success) {
118 $exception = Requests_Exception_HTTP::get_class($this->status_code);
119 throw new $exception(null, $this);
120 }
121 }
122 }
123