Commit 1472d53e authored by Chris Graham's avatar Chris Graham

Fixed MANTIS-4053 (Some HTTP status codes not properly handled)

parent 49c9db26
This diff was suppressed by a .gitattributes entry.
......@@ -1455,7 +1455,7 @@ function _http_download_file($url, $byte_limit = null, $trigger_error = true, $n
if ($HTTP_DOWNLOAD_URL == $_url) {
$HTTP_DOWNLOAD_URL = $url;
}
$HTTP_MESSAGE = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
$HTTP_MESSAGE = _fix_non_standard_statuses(strval(curl_getinfo($ch, CURLINFO_HTTP_CODE)));
if ($HTTP_MESSAGE == '206') {
$HTTP_MESSAGE = '200'; // We don't care about partial-content return code, as Composr implementation gets ranges differently and we check '200' as a return result
}
......@@ -1832,7 +1832,7 @@ function _http_download_file($url, $byte_limit = null, $trigger_error = true, $n
// 400/500=Internal error
// 405=Method not allowed
$HTTP_MESSAGE = $matches[2];
$HTTP_MESSAGE = _fix_non_standard_statuses($matches[2]);
switch ($matches[2]) {
case '301':
case '302':
......@@ -1840,6 +1840,7 @@ function _http_download_file($url, $byte_limit = null, $trigger_error = true, $n
// We'll expect a location header
break;
case '200':
case '201':
// Good
break;
case '401':
......@@ -2376,3 +2377,17 @@ function _detect_character_encoding($out)
return $out;
}
/**
* Fixup non-standard status codes to standard ones.
*
* @param string $status Status returned
* @return string Fixed status
*
* @ignore
*/
function _fix_non_standard_statuses($status)
{
$status = preg_replace('#^(\d\d\d)\.\d+$#', '$1', $status); // IIS
return $status;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment