summaryrefslogtreecommitdiffstats
path: root/inc/download.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-03-21 14:41:37 +0100
committerSimon Rettberg2017-03-21 14:41:37 +0100
commit422d95a745d9b177da2d68eb815f3cd8ac42f351 (patch)
treedefeb1f47551aabe5ea2210c86b0f2814b882068 /inc/download.inc.php
parentFix a couple of warnings and notices from error.log (diff)
downloadslx-admin-422d95a745d9b177da2d68eb815f3cd8ac42f351.tar.gz
slx-admin-422d95a745d9b177da2d68eb815f3cd8ac42f351.tar.xz
slx-admin-422d95a745d9b177da2d68eb815f3cd8ac42f351.zip
[inc/Download] Properly return final HTTP status code for redirected requests
Diffstat (limited to 'inc/download.inc.php')
-rw-r--r--inc/download.inc.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/inc/download.inc.php b/inc/download.inc.php
index 51601545..a2054f78 100644
--- a/inc/download.inc.php
+++ b/inc/download.inc.php
@@ -49,8 +49,8 @@ class Download
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$head = self::getContents($head);
- if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) {
- $code = (int) $out[1];
+ if (preg_match_all('#^HTTP/\d+\.\d+ (\d+) #m', $head, $out)) {
+ $code = (int) array_pop($out[1]);
} else {
$code = 999;
}
@@ -83,8 +83,8 @@ class Download
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
$data = curl_exec($ch);
$head = self::getContents($head);
- if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) {
- $code = (int) $out[1];
+ if (preg_match_all('#^HTTP/\d+\.\d+ (\d+) #m', $head, $out)) {
+ $code = (int) array_pop($out[1]);
} else {
$code = 999;
}
@@ -116,8 +116,8 @@ class Download
@unlink($target);
return false;
}
- if (preg_match_all('#\bHTTP/\d+\.\d+ (\d+) #', $head, $out, PREG_SET_ORDER)) {
- $code = (int) $out[count($out) - 1][1];
+ if (preg_match_all('#^HTTP/\d+\.\d+ (\d+) #m', $head, $out)) {
+ $code = (int) array_pop($out[1]);
} else {
$code = '999 ' . curl_error($ch);
}