1
0
Fork 0

Curl Response Refactoring

- extended Curl to parse Curl Response
- refactored Network::curl()
- replaced every Network::curl() execution with the new Curl container
This commit is contained in:
Philipp Holzer 2018-10-10 21:08:43 +02:00
commit 2dec8895a9
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
20 changed files with 466 additions and 382 deletions

View file

@ -60,12 +60,12 @@ function parse_url_content(App $a)
// the URL with the corresponding BBCode media tag
$redirects = 0;
// Fetch the header of the URL
$result = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
$curlResponse = Network::curl($url, false, $redirects, ['novalidate' => true, 'nobody' => true]);
if ($result['success']) {
if ($curlResponse->isSuccess()) {
// Convert the header fields into an array
$hdrs = [];
$h = explode("\n", $result['header']);
$h = explode("\n", $curlResponse->getHeader());
foreach ($h as $l) {
$header = array_map('trim', explode(':', trim($l), 2));
if (count($header) == 2) {