Skip to content

Commit 6c5e85a

Browse files
Use getallheaders() instead of apache_request_headers()
On Dockerized environment where apache and php are running in separate containers, there are no `apache_` methods. The `getallheaders()` method is an alias to the `apache_request_headers()` method, therefore the behaviour will be identical. The reason to use the alias function, eh `getallheaders()` is that there are polyfills to `getallheaders` function (like ralouphie/getallheaders used by Guzzle, very popular HTTP library), but there are no polyfills to the `apache_request_headers` function.
1 parent 26091f7 commit 6c5e85a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libs/csrf/csrfprotector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ private static function getTokenFromRequest()
267267
return $_POST[self::$config['CSRFP_TOKEN']];
268268
}
269269

270-
if (function_exists('apache_request_headers')) {
271-
$apacheRequestHeaders = apache_request_headers();
272-
if (isset($apacheRequestHeaders[self::$config['CSRFP_TOKEN']])) {
273-
return $apacheRequestHeaders[self::$config['CSRFP_TOKEN']];
270+
if (function_exists('getallheaders')) {
271+
$requestHeaders = getallheaders();
272+
if (isset($requestHeaders[self::$config['CSRFP_TOKEN']])) {
273+
return $requestHeaders[self::$config['CSRFP_TOKEN']];
274274
}
275275
}
276276

0 commit comments

Comments
 (0)