Explorar o código

GReaderAPI: compare Authorization:GoogleLogin (and other) header case insensitive (#9534)

According to the HTTP spec headers are case insensitive, and in HTTP2 and 3 it even states that they should be transmitted lowercase.

As such I found it quite confusing to receive a 401 response when I (unintentionally) sent a lowercase `authorization`, which is the default in reqwest (<https://github.com/seanmonstar/reqwest>). But afaict it's not wrong to do so.
Frans de Jonge hai 3 horas
pai
achega
3e4e05f3ff
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      p/api/greader.php

+ 5 - 2
p/api/greader.php

@@ -61,8 +61,11 @@ function headerVariable(string $headerName, string $varName): string {
 		$header = '' . $_SERVER['REDIRECT_' . $upName];
 	} elseif (function_exists('getallheaders')) {
 		$ALL_HEADERS = getallheaders();
-		if (is_string($ALL_HEADERS[$headerName] ?? null)) {
-			$header = '' . $ALL_HEADERS[$headerName];
+		foreach ($ALL_HEADERS as $name => $value) {
+			if (is_string($name) && strcasecmp($name, $headerName) === 0 && is_string($value)) {
+				$header = $value;
+				break;
+			}
 		}
 	}
 	parse_str($header, $pairs);