@@ -11,88 +11,88 @@ |
||
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | 13 | class Requests_Response_Headers extends Requests_Utility_CaseInsensitiveDictionary { |
14 | - /** |
|
15 | - * Get the given header |
|
16 | - * |
|
17 | - * Unlike {@see self::getValues()}, this returns a string. If there are |
|
18 | - * multiple values, it concatenates them with a comma as per RFC2616. |
|
19 | - * |
|
20 | - * Avoid using this where commas may be used unquoted in values, such as |
|
21 | - * Set-Cookie headers. |
|
22 | - * |
|
23 | - * @param string $key |
|
24 | - * @return string Header value |
|
25 | - */ |
|
26 | - public function offsetGet($key) { |
|
27 | - $key = strtolower($key); |
|
28 | - if (!isset($this->data[$key])) { |
|
29 | - return null; |
|
30 | - } |
|
14 | + /** |
|
15 | + * Get the given header |
|
16 | + * |
|
17 | + * Unlike {@see self::getValues()}, this returns a string. If there are |
|
18 | + * multiple values, it concatenates them with a comma as per RFC2616. |
|
19 | + * |
|
20 | + * Avoid using this where commas may be used unquoted in values, such as |
|
21 | + * Set-Cookie headers. |
|
22 | + * |
|
23 | + * @param string $key |
|
24 | + * @return string Header value |
|
25 | + */ |
|
26 | + public function offsetGet($key) { |
|
27 | + $key = strtolower($key); |
|
28 | + if (!isset($this->data[$key])) { |
|
29 | + return null; |
|
30 | + } |
|
31 | 31 | |
32 | - return $this->flatten($this->data[$key]); |
|
33 | - } |
|
32 | + return $this->flatten($this->data[$key]); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Set the given item |
|
37 | - * |
|
38 | - * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) |
|
39 | - * |
|
40 | - * @param string $key Item name |
|
41 | - * @param string $value Item value |
|
42 | - */ |
|
43 | - public function offsetSet($key, $value) { |
|
44 | - if ($key === null) { |
|
45 | - throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
|
46 | - } |
|
35 | + /** |
|
36 | + * Set the given item |
|
37 | + * |
|
38 | + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) |
|
39 | + * |
|
40 | + * @param string $key Item name |
|
41 | + * @param string $value Item value |
|
42 | + */ |
|
43 | + public function offsetSet($key, $value) { |
|
44 | + if ($key === null) { |
|
45 | + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
|
46 | + } |
|
47 | 47 | |
48 | - $key = strtolower($key); |
|
48 | + $key = strtolower($key); |
|
49 | 49 | |
50 | - if (!isset($this->data[$key])) { |
|
51 | - $this->data[$key] = array(); |
|
52 | - } |
|
50 | + if (!isset($this->data[$key])) { |
|
51 | + $this->data[$key] = array(); |
|
52 | + } |
|
53 | 53 | |
54 | - $this->data[$key][] = $value; |
|
55 | - } |
|
54 | + $this->data[$key][] = $value; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Get all values for a given header |
|
59 | - * |
|
60 | - * @param string $key |
|
61 | - * @return array Header values |
|
62 | - */ |
|
63 | - public function getValues($key) { |
|
64 | - $key = strtolower($key); |
|
65 | - if (!isset($this->data[$key])) { |
|
66 | - return null; |
|
67 | - } |
|
57 | + /** |
|
58 | + * Get all values for a given header |
|
59 | + * |
|
60 | + * @param string $key |
|
61 | + * @return array Header values |
|
62 | + */ |
|
63 | + public function getValues($key) { |
|
64 | + $key = strtolower($key); |
|
65 | + if (!isset($this->data[$key])) { |
|
66 | + return null; |
|
67 | + } |
|
68 | 68 | |
69 | - return $this->data[$key]; |
|
70 | - } |
|
69 | + return $this->data[$key]; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Flattens a value into a string |
|
74 | - * |
|
75 | - * Converts an array into a string by imploding values with a comma, as per |
|
76 | - * RFC2616's rules for folding headers. |
|
77 | - * |
|
78 | - * @param string|array $value Value to flatten |
|
79 | - * @return string Flattened value |
|
80 | - */ |
|
81 | - public function flatten($value) { |
|
82 | - if (is_array($value)) { |
|
83 | - $value = implode(',', $value); |
|
84 | - } |
|
72 | + /** |
|
73 | + * Flattens a value into a string |
|
74 | + * |
|
75 | + * Converts an array into a string by imploding values with a comma, as per |
|
76 | + * RFC2616's rules for folding headers. |
|
77 | + * |
|
78 | + * @param string|array $value Value to flatten |
|
79 | + * @return string Flattened value |
|
80 | + */ |
|
81 | + public function flatten($value) { |
|
82 | + if (is_array($value)) { |
|
83 | + $value = implode(',', $value); |
|
84 | + } |
|
85 | 85 | |
86 | - return $value; |
|
87 | - } |
|
86 | + return $value; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Get an iterator for the data |
|
91 | - * |
|
92 | - * Converts the internal |
|
93 | - * @return ArrayIterator |
|
94 | - */ |
|
95 | - public function getIterator() { |
|
96 | - return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten')); |
|
97 | - } |
|
89 | + /** |
|
90 | + * Get an iterator for the data |
|
91 | + * |
|
92 | + * Converts the internal |
|
93 | + * @return ArrayIterator |
|
94 | + */ |
|
95 | + public function getIterator() { |
|
96 | + return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten')); |
|
97 | + } |
|
98 | 98 | } |
@@ -13,33 +13,33 @@ |
||
13 | 13 | * @subpackage Utilities |
14 | 14 | */ |
15 | 15 | class Requests_Utility_FilteredIterator extends ArrayIterator { |
16 | - /** |
|
17 | - * Callback to run as a filter |
|
18 | - * |
|
19 | - * @var callable |
|
20 | - */ |
|
21 | - protected $callback; |
|
16 | + /** |
|
17 | + * Callback to run as a filter |
|
18 | + * |
|
19 | + * @var callable |
|
20 | + */ |
|
21 | + protected $callback; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Create a new iterator |
|
25 | - * |
|
26 | - * @param array $data |
|
27 | - * @param callable $callback Callback to be called on each value |
|
28 | - */ |
|
29 | - public function __construct($data, $callback) { |
|
30 | - parent::__construct($data); |
|
23 | + /** |
|
24 | + * Create a new iterator |
|
25 | + * |
|
26 | + * @param array $data |
|
27 | + * @param callable $callback Callback to be called on each value |
|
28 | + */ |
|
29 | + public function __construct($data, $callback) { |
|
30 | + parent::__construct($data); |
|
31 | 31 | |
32 | - $this->callback = $callback; |
|
33 | - } |
|
32 | + $this->callback = $callback; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Get the current item's value after filtering |
|
37 | - * |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function current() { |
|
41 | - $value = parent::current(); |
|
42 | - $value = call_user_func($this->callback, $value); |
|
43 | - return $value; |
|
44 | - } |
|
35 | + /** |
|
36 | + * Get the current item's value after filtering |
|
37 | + * |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function current() { |
|
41 | + $value = parent::current(); |
|
42 | + $value = call_user_func($this->callback, $value); |
|
43 | + return $value; |
|
44 | + } |
|
45 | 45 | } |
@@ -13,91 +13,91 @@ |
||
13 | 13 | * @subpackage Utilities |
14 | 14 | */ |
15 | 15 | class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate { |
16 | - /** |
|
17 | - * Actual item data |
|
18 | - * |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $data = array(); |
|
16 | + /** |
|
17 | + * Actual item data |
|
18 | + * |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $data = array(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * Creates a case insensitive dictionary. |
|
25 | - * |
|
26 | - * @param array $data Dictionary/map to convert to case-insensitive |
|
27 | - */ |
|
28 | - public function __construct(array $data = array()) { |
|
29 | - foreach ($data as $key => $value) { |
|
30 | - $this->offsetSet($key, $value); |
|
31 | - } |
|
32 | - } |
|
23 | + /** |
|
24 | + * Creates a case insensitive dictionary. |
|
25 | + * |
|
26 | + * @param array $data Dictionary/map to convert to case-insensitive |
|
27 | + */ |
|
28 | + public function __construct(array $data = array()) { |
|
29 | + foreach ($data as $key => $value) { |
|
30 | + $this->offsetSet($key, $value); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Check if the given item exists |
|
36 | - * |
|
37 | - * @param string $key Item key |
|
38 | - * @return boolean Does the item exist? |
|
39 | - */ |
|
40 | - public function offsetExists($key) { |
|
41 | - $key = strtolower($key); |
|
42 | - return isset($this->data[$key]); |
|
43 | - } |
|
34 | + /** |
|
35 | + * Check if the given item exists |
|
36 | + * |
|
37 | + * @param string $key Item key |
|
38 | + * @return boolean Does the item exist? |
|
39 | + */ |
|
40 | + public function offsetExists($key) { |
|
41 | + $key = strtolower($key); |
|
42 | + return isset($this->data[$key]); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get the value for the item |
|
47 | - * |
|
48 | - * @param string $key Item key |
|
49 | - * @return string Item value |
|
50 | - */ |
|
51 | - public function offsetGet($key) { |
|
52 | - $key = strtolower($key); |
|
53 | - if (!isset($this->data[$key])) { |
|
54 | - return null; |
|
55 | - } |
|
45 | + /** |
|
46 | + * Get the value for the item |
|
47 | + * |
|
48 | + * @param string $key Item key |
|
49 | + * @return string Item value |
|
50 | + */ |
|
51 | + public function offsetGet($key) { |
|
52 | + $key = strtolower($key); |
|
53 | + if (!isset($this->data[$key])) { |
|
54 | + return null; |
|
55 | + } |
|
56 | 56 | |
57 | - return $this->data[$key]; |
|
58 | - } |
|
57 | + return $this->data[$key]; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Set the given item |
|
62 | - * |
|
63 | - * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) |
|
64 | - * |
|
65 | - * @param string $key Item name |
|
66 | - * @param string $value Item value |
|
67 | - */ |
|
68 | - public function offsetSet($key, $value) { |
|
69 | - if ($key === null) { |
|
70 | - throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
|
71 | - } |
|
60 | + /** |
|
61 | + * Set the given item |
|
62 | + * |
|
63 | + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) |
|
64 | + * |
|
65 | + * @param string $key Item name |
|
66 | + * @param string $value Item value |
|
67 | + */ |
|
68 | + public function offsetSet($key, $value) { |
|
69 | + if ($key === null) { |
|
70 | + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); |
|
71 | + } |
|
72 | 72 | |
73 | - $key = strtolower($key); |
|
74 | - $this->data[$key] = $value; |
|
75 | - } |
|
73 | + $key = strtolower($key); |
|
74 | + $this->data[$key] = $value; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Unset the given header |
|
79 | - * |
|
80 | - * @param string $key |
|
81 | - */ |
|
82 | - public function offsetUnset($key) { |
|
83 | - unset($this->data[strtolower($key)]); |
|
84 | - } |
|
77 | + /** |
|
78 | + * Unset the given header |
|
79 | + * |
|
80 | + * @param string $key |
|
81 | + */ |
|
82 | + public function offsetUnset($key) { |
|
83 | + unset($this->data[strtolower($key)]); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get an iterator for the data |
|
88 | - * |
|
89 | - * @return ArrayIterator |
|
90 | - */ |
|
91 | - public function getIterator() { |
|
92 | - return new ArrayIterator($this->data); |
|
93 | - } |
|
86 | + /** |
|
87 | + * Get an iterator for the data |
|
88 | + * |
|
89 | + * @return ArrayIterator |
|
90 | + */ |
|
91 | + public function getIterator() { |
|
92 | + return new ArrayIterator($this->data); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Get the headers as an array |
|
97 | - * |
|
98 | - * @return array Header data |
|
99 | - */ |
|
100 | - public function getAll() { |
|
101 | - return $this->data; |
|
102 | - } |
|
95 | + /** |
|
96 | + * Get the headers as an array |
|
97 | + * |
|
98 | + * @return array Header data |
|
99 | + */ |
|
100 | + public function getAll() { |
|
101 | + return $this->data; |
|
102 | + } |
|
103 | 103 | } |
@@ -13,21 +13,21 @@ |
||
13 | 13 | * @subpackage Utilities |
14 | 14 | */ |
15 | 15 | interface Requests_Hooker { |
16 | - /** |
|
17 | - * Register a callback for a hook |
|
18 | - * |
|
19 | - * @param string $hook Hook name |
|
20 | - * @param callback $callback Function/method to call on event |
|
21 | - * @param int $priority Priority number. <0 is executed earlier, >0 is executed later |
|
22 | - */ |
|
23 | - public function register($hook, $callback, $priority = 0); |
|
16 | + /** |
|
17 | + * Register a callback for a hook |
|
18 | + * |
|
19 | + * @param string $hook Hook name |
|
20 | + * @param callback $callback Function/method to call on event |
|
21 | + * @param int $priority Priority number. <0 is executed earlier, >0 is executed later |
|
22 | + */ |
|
23 | + public function register($hook, $callback, $priority = 0); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Dispatch a message |
|
27 | - * |
|
28 | - * @param string $hook Hook name |
|
29 | - * @param array $parameters Parameters to pass to callbacks |
|
30 | - * @return boolean Successfulness |
|
31 | - */ |
|
32 | - public function dispatch($hook, $parameters = array()); |
|
25 | + /** |
|
26 | + * Dispatch a message |
|
27 | + * |
|
28 | + * @param string $hook Hook name |
|
29 | + * @param array $parameters Parameters to pass to callbacks |
|
30 | + * @return boolean Successfulness |
|
31 | + */ |
|
32 | + public function dispatch($hook, $parameters = array()); |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -13,17 +13,17 @@ |
||
13 | 13 | * @package Requests |
14 | 14 | */ |
15 | 15 | class Requests_Exception_HTTP_431 extends Requests_Exception_HTTP { |
16 | - /** |
|
17 | - * HTTP status code |
|
18 | - * |
|
19 | - * @var integer |
|
20 | - */ |
|
21 | - protected $code = 431; |
|
16 | + /** |
|
17 | + * HTTP status code |
|
18 | + * |
|
19 | + * @var integer |
|
20 | + */ |
|
21 | + protected $code = 431; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Reason phrase |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $reason = 'Request Header Fields Too Large'; |
|
23 | + /** |
|
24 | + * Reason phrase |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $reason = 'Request Header Fields Too Large'; |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -11,17 +11,17 @@ |
||
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | 13 | class Requests_Exception_HTTP_415 extends Requests_Exception_HTTP { |
14 | - /** |
|
15 | - * HTTP status code |
|
16 | - * |
|
17 | - * @var integer |
|
18 | - */ |
|
19 | - protected $code = 415; |
|
14 | + /** |
|
15 | + * HTTP status code |
|
16 | + * |
|
17 | + * @var integer |
|
18 | + */ |
|
19 | + protected $code = 415; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Reason phrase |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $reason = 'Unsupported Media Type'; |
|
21 | + /** |
|
22 | + * Reason phrase |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $reason = 'Unsupported Media Type'; |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -11,17 +11,17 @@ |
||
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | 13 | class Requests_Exception_HTTP_403 extends Requests_Exception_HTTP { |
14 | - /** |
|
15 | - * HTTP status code |
|
16 | - * |
|
17 | - * @var integer |
|
18 | - */ |
|
19 | - protected $code = 403; |
|
14 | + /** |
|
15 | + * HTTP status code |
|
16 | + * |
|
17 | + * @var integer |
|
18 | + */ |
|
19 | + protected $code = 403; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Reason phrase |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $reason = 'Forbidden'; |
|
21 | + /** |
|
22 | + * Reason phrase |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $reason = 'Forbidden'; |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -11,34 +11,34 @@ |
||
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | 13 | class Requests_Exception_HTTP_Unknown extends Requests_Exception_HTTP { |
14 | - /** |
|
15 | - * HTTP status code |
|
16 | - * |
|
17 | - * @var integer|bool Code if available, false if an error occurred |
|
18 | - */ |
|
19 | - protected $code = 0; |
|
14 | + /** |
|
15 | + * HTTP status code |
|
16 | + * |
|
17 | + * @var integer|bool Code if available, false if an error occurred |
|
18 | + */ |
|
19 | + protected $code = 0; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Reason phrase |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $reason = 'Unknown'; |
|
21 | + /** |
|
22 | + * Reason phrase |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $reason = 'Unknown'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Create a new exception |
|
30 | - * |
|
31 | - * If `$data` is an instance of {@see Requests_Response}, uses the status |
|
32 | - * code from it. Otherwise, sets as 0 |
|
33 | - * |
|
34 | - * @param string|null $reason Reason phrase |
|
35 | - * @param mixed $data Associated data |
|
36 | - */ |
|
37 | - public function __construct($reason = null, $data = null) { |
|
38 | - if ($data instanceof Requests_Response) { |
|
39 | - $this->code = $data->status_code; |
|
40 | - } |
|
28 | + /** |
|
29 | + * Create a new exception |
|
30 | + * |
|
31 | + * If `$data` is an instance of {@see Requests_Response}, uses the status |
|
32 | + * code from it. Otherwise, sets as 0 |
|
33 | + * |
|
34 | + * @param string|null $reason Reason phrase |
|
35 | + * @param mixed $data Associated data |
|
36 | + */ |
|
37 | + public function __construct($reason = null, $data = null) { |
|
38 | + if ($data instanceof Requests_Response) { |
|
39 | + $this->code = $data->status_code; |
|
40 | + } |
|
41 | 41 | |
42 | - parent::__construct($reason, $data); |
|
43 | - } |
|
42 | + parent::__construct($reason, $data); |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -11,17 +11,17 @@ |
||
11 | 11 | * @package Requests |
12 | 12 | */ |
13 | 13 | class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP { |
14 | - /** |
|
15 | - * HTTP status code |
|
16 | - * |
|
17 | - * @var integer |
|
18 | - */ |
|
19 | - protected $code = 414; |
|
14 | + /** |
|
15 | + * HTTP status code |
|
16 | + * |
|
17 | + * @var integer |
|
18 | + */ |
|
19 | + protected $code = 414; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Reason phrase |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $reason = 'Request-URI Too Large'; |
|
21 | + /** |
|
22 | + * Reason phrase |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $reason = 'Request-URI Too Large'; |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |