Fix the HTTP 1.0 status code and properly detect 1.0 vs 1.1&2.0

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2018-03-13 09:22:26 +01:00
parent e758cfcdc8
commit 53a899a1f5
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 8 additions and 8 deletions

View File

@ -29,10 +29,10 @@ $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare
if($token !== '') { if($token !== '') {
$protocol = \OC::$server->getRequest()->getHttpProtocol(); $protocol = \OC::$server->getRequest()->getHttpProtocol();
if ($protocol == 'HTTP/1.1') { if ($protocol == 'HTTP/1.0') {
$status = '307 Temporary Redirect'; $status = '302 Found';
} else { } else {
$status = '304 Found'; $status = '307 Temporary Redirect';
} }
header($protocol.' ' . $status); header($protocol.' ' . $status);
header('Location: ' . $urlGenerator->linkToRoute($route, array('token' => $token))); header('Location: ' . $urlGenerator->linkToRoute($route, array('token' => $token)));

View File

@ -31,7 +31,7 @@
*/ */
class OC_Response { class OC_Response {
const STATUS_FOUND = 304; const STATUS_FOUND = 302;
const STATUS_NOT_MODIFIED = 304; const STATUS_NOT_MODIFIED = 304;
const STATUS_TEMPORARY_REDIRECT = 307; const STATUS_TEMPORARY_REDIRECT = 307;
const STATUS_BAD_REQUEST = 400; const STATUS_BAD_REQUEST = 400;
@ -51,12 +51,12 @@ class OC_Response {
$status = $status . ' Not Modified'; $status = $status . ' Not Modified';
break; break;
case self::STATUS_TEMPORARY_REDIRECT: case self::STATUS_TEMPORARY_REDIRECT:
if ($protocol == 'HTTP/1.1') { if ($protocol == 'HTTP/1.0') {
$status = $status . ' Temporary Redirect';
break;
} else {
$status = self::STATUS_FOUND; $status = self::STATUS_FOUND;
// fallthrough // fallthrough
} else {
$status = $status . ' Temporary Redirect';
break;
} }
case self::STATUS_FOUND; case self::STATUS_FOUND;
$status = $status . ' Found'; $status = $status . ' Found';