1 | <?php |
||
12 | class HttpAdapter implements AdapterInterface |
||
13 | { |
||
14 | /** |
||
15 | * The base URL. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $base; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $context; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $supportsHead; |
||
30 | |||
31 | /** |
||
32 | * The visibility of this adapter. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $visibility = AdapterInterface::VISIBILITY_PUBLIC; |
||
37 | |||
38 | /** |
||
39 | * Constructs an HttpAdapter object. |
||
40 | * |
||
41 | * @param string $base The base URL |
||
42 | * @param bool $supportsHead Whether the endpoint supports HEAD requests |
||
43 | * @param array $context Context options |
||
44 | */ |
||
45 | 63 | public function __construct($base, $supportsHead = true, array $context = []) |
|
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | 3 | public function copy($path, $newpath) |
|
76 | |||
77 | /** |
||
78 | * @inheritdoc |
||
79 | */ |
||
80 | 3 | public function createDir($path, Config $config) |
|
84 | |||
85 | /** |
||
86 | * @inheritdoc |
||
87 | */ |
||
88 | 3 | public function delete($path) |
|
92 | |||
93 | /** |
||
94 | * @inheritdoc |
||
95 | */ |
||
96 | 3 | public function deleteDir($path) |
|
100 | |||
101 | /** |
||
102 | * Returns the base path. |
||
103 | * |
||
104 | * @return string The base path |
||
105 | */ |
||
106 | 3 | public function getBase() |
|
110 | |||
111 | /** |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | 12 | public function getMetadata($path) |
|
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | 3 | public function getMimetype($path) |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 3 | public function getSize($path) |
|
138 | |||
139 | /** |
||
140 | * @inheritdoc |
||
141 | */ |
||
142 | 3 | public function getTimestamp($path) |
|
146 | |||
147 | /** |
||
148 | * @inheritdoc |
||
149 | */ |
||
150 | 3 | public function getVisibility($path) |
|
157 | |||
158 | /** |
||
159 | * @inheritdoc |
||
160 | */ |
||
161 | 3 | public function has($path) |
|
165 | |||
166 | /** |
||
167 | * @inheritdoc |
||
168 | */ |
||
169 | 3 | public function listContents($directory = '', $recursive = false) |
|
173 | |||
174 | /** |
||
175 | * @inheritdoc |
||
176 | */ |
||
177 | 3 | public function read($path) |
|
188 | |||
189 | /** |
||
190 | * @inheritdoc |
||
191 | */ |
||
192 | 3 | public function readStream($path) |
|
206 | |||
207 | /** |
||
208 | * @inheritdoc |
||
209 | */ |
||
210 | 3 | public function rename($path, $newpath) |
|
214 | |||
215 | /** |
||
216 | * Sets the HTTP context options. |
||
217 | * |
||
218 | * @param array $context The context options |
||
219 | */ |
||
220 | 3 | public function setContext(array $context) |
|
224 | |||
225 | /** |
||
226 | * @inheritdoc |
||
227 | */ |
||
228 | 3 | public function setVisibility($path, $visibility) |
|
232 | |||
233 | /** |
||
234 | * @inheritdoc |
||
235 | */ |
||
236 | 3 | public function update($path, $contents, Config $conf) |
|
240 | |||
241 | /** |
||
242 | * @inheritdoc |
||
243 | */ |
||
244 | 3 | public function updateStream($path, $resource, Config $config) |
|
248 | |||
249 | /** |
||
250 | * @inheritdoc |
||
251 | */ |
||
252 | 3 | public function write($path, $contents, Config $config) |
|
256 | |||
257 | /** |
||
258 | * @inheritdoc |
||
259 | */ |
||
260 | 3 | public function writeStream($path, $resource, Config $config) |
|
264 | |||
265 | /** |
||
266 | * Returns the URL to perform an HTTP request. |
||
267 | * |
||
268 | * @param string $path |
||
269 | * |
||
270 | * @return string |
||
271 | */ |
||
272 | 21 | protected function buildUrl($path) |
|
279 | |||
280 | /** |
||
281 | * Performs a HEAD request. |
||
282 | * |
||
283 | * @param string $path |
||
284 | * |
||
285 | * @return array|false |
||
286 | */ |
||
287 | 15 | protected function head($path) |
|
308 | |||
309 | /** |
||
310 | * Parses the timestamp out of headers. |
||
311 | * |
||
312 | * @param array $headers |
||
313 | * |
||
314 | * @return int|false |
||
315 | */ |
||
316 | 12 | protected function parseTimestamp(array $headers) |
|
324 | |||
325 | /** |
||
326 | * Parses metadata out of response headers. |
||
327 | * |
||
328 | * @param string $path |
||
329 | * @param array $headers |
||
330 | * |
||
331 | * @return array |
||
332 | */ |
||
333 | 12 | protected function parseMetadata($path, array $headers) |
|
351 | |||
352 | /** |
||
353 | * Parses the mimetype out of response headers. |
||
354 | * |
||
355 | * @param string $path |
||
356 | * @param array $headers |
||
357 | * |
||
358 | * @return string |
||
359 | */ |
||
360 | 12 | protected function parseMimeType($path, array $headers) |
|
374 | } |
||
375 |