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