1 | <?php |
||
15 | class Requests_Cookie_Jar implements ArrayAccess, IteratorAggregate { |
||
16 | /** |
||
17 | * Actual item data |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $cookies = array(); |
||
22 | |||
23 | /** |
||
24 | * Create a new jar |
||
25 | * |
||
26 | * @param array $cookies Existing cookie values |
||
27 | */ |
||
28 | public function __construct($cookies = array()) { |
||
31 | |||
32 | /** |
||
33 | * Normalise cookie data into a Requests_Cookie |
||
34 | * |
||
35 | * @param string|Requests_Cookie $cookie |
||
36 | * @return Requests_Cookie |
||
37 | */ |
||
38 | public function normalize_cookie($cookie, $key = null) { |
||
45 | |||
46 | /** |
||
47 | * Normalise cookie data into a Requests_Cookie |
||
48 | * |
||
49 | * @codeCoverageIgnore |
||
50 | * @deprecated Use {@see Requests_Cookie_Jar::normalize_cookie} |
||
51 | * @return Requests_Cookie |
||
52 | */ |
||
53 | public function normalizeCookie($cookie, $key = null) { |
||
56 | |||
57 | /** |
||
58 | * Check if the given item exists |
||
59 | * |
||
60 | * @param string $key Item key |
||
61 | * @return boolean Does the item exist? |
||
62 | */ |
||
63 | public function offsetExists($key) { |
||
66 | |||
67 | /** |
||
68 | * Get the value for the item |
||
69 | * |
||
70 | * @param string $key Item key |
||
71 | * @return string Item value |
||
72 | */ |
||
73 | public function offsetGet($key) { |
||
80 | |||
81 | /** |
||
82 | * Set the given item |
||
83 | * |
||
84 | * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) |
||
85 | * |
||
86 | * @param string $key Item name |
||
87 | * @param string $value Item value |
||
88 | */ |
||
89 | public function offsetSet($key, $value) { |
||
96 | |||
97 | /** |
||
98 | * Unset the given header |
||
99 | * |
||
100 | * @param string $key |
||
101 | */ |
||
102 | public function offsetUnset($key) { |
||
105 | |||
106 | /** |
||
107 | * Get an iterator for the data |
||
108 | * |
||
109 | * @return ArrayIterator |
||
110 | */ |
||
111 | public function getIterator() { |
||
114 | |||
115 | /** |
||
116 | * Register the cookie handler with the request's hooking system |
||
117 | * |
||
118 | * @param Requests_Hooker $hooks Hooking system |
||
119 | */ |
||
120 | public function register(Requests_Hooker $hooks) { |
||
124 | |||
125 | /** |
||
126 | * Add Cookie header to a request if we have any |
||
127 | * |
||
128 | * As per RFC 6265, cookies are separated by '; ' |
||
129 | * |
||
130 | * @param string $url |
||
131 | * @param array $headers |
||
132 | * @param array $data |
||
133 | * @param string $type |
||
134 | * @param array $options |
||
135 | */ |
||
136 | public function before_request($url, &$headers, &$data, &$type, &$options) { |
||
159 | |||
160 | /** |
||
161 | * Parse all cookies from a response and attach them to the response |
||
162 | * |
||
163 | * @var Requests_Response $response |
||
164 | */ |
||
165 | public function before_redirect_check(Requests_Response &$return) { |
||
175 | } |