1 | <?php |
||
17 | class CurlRemoteFilesystem extends Util\RemoteFilesystem |
||
18 | { |
||
19 | protected $io; |
||
20 | protected $config; |
||
21 | protected $options; |
||
22 | |||
23 | protected $retryAuthFailure = true; |
||
24 | |||
25 | protected $pluginConfig; |
||
26 | |||
27 | private $_lastHeaders = array(); |
||
28 | |||
29 | // global flags |
||
30 | private $_retry = false; |
||
31 | |||
32 | /** @var Aspects\JoinPoint */ |
||
33 | public $onPreDownload; |
||
34 | |||
35 | /** @var Aspects\JoinPoint */ |
||
36 | public $onPostDownload; |
||
37 | |||
38 | /** |
||
39 | * @param IO\IOInterface $io |
||
40 | * @param CConfig $config |
||
41 | * @param array $options |
||
42 | */ |
||
43 | 9 | public function __construct(IO\IOInterface $io, CConfig $config, array $options = array()) |
|
49 | |||
50 | 9 | public function setPluginConfig(array $pluginConfig) |
|
54 | |||
55 | /** |
||
56 | * Copy the remote file in local. |
||
57 | * |
||
58 | * @param string $origin host/domain text |
||
59 | * @param string $fileUrl targeturl |
||
60 | * @param string $fileName the local filename |
||
61 | * @param bool $progress Display the progression |
||
62 | * @param array $options Additional context options |
||
63 | * |
||
64 | * @return bool true |
||
65 | */ |
||
66 | 4 | public function copy($origin, $fileUrl, $fileName, $progress = true, $options = array()) |
|
86 | |||
87 | /** |
||
88 | * Get the content. |
||
89 | * |
||
90 | * @param string $origin The origin URL |
||
91 | * @param string $fileUrl The file URL |
||
92 | * @param bool $progress Display the progression |
||
93 | * @param array $options Additional context options |
||
94 | * |
||
95 | * @return bool|string The content |
||
96 | */ |
||
97 | 1 | public function getContents($origin, $fileUrl, $progress = true, $options = array()) |
|
109 | |||
110 | /** |
||
111 | * @param string $origin |
||
112 | * @param string $fileUrl |
||
113 | * @param boolean $progress |
||
114 | * @param \Closure $exec |
||
115 | */ |
||
116 | 5 | protected function fetch($origin, $fileUrl, $progress, $options, $exec) |
|
157 | |||
158 | /** |
||
159 | * Retrieve the options set in the constructor |
||
160 | * |
||
161 | * @return array Options |
||
162 | */ |
||
163 | 1 | public function getOptions() |
|
167 | |||
168 | /** |
||
169 | * Returns the headers of the last request |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | 1 | public function getLastHeaders() |
|
177 | |||
178 | /** |
||
179 | * @internal |
||
180 | * @param resource $ch |
||
181 | * @param Aspects\HttpGetRequest $request |
||
182 | * @return array {int, Aspects\HttpGetResponse} |
||
183 | */ |
||
184 | 5 | public function exec($ch, Aspects\HttpGetRequest $request) |
|
204 | |||
205 | /** |
||
206 | * @internal |
||
207 | */ |
||
208 | 4 | public function progress() |
|
226 | |||
227 | /** |
||
228 | * @internal |
||
229 | * @param resource $ch |
||
230 | * @param string $header |
||
231 | * @return int |
||
232 | */ |
||
233 | 5 | public function processHeader($ch, $header) |
|
238 | |||
239 | 3 | protected function promptAuth(Aspects\HttpGetRequest $req, Aspects\HttpGetResponse $res) |
|
244 | } |
||
245 |