From 81dc45bd78a02b277df953955fec65538e1a6a3c Mon Sep 17 00:00:00 2001 From: SagePtr Date: Sat, 23 Feb 2019 00:14:04 +0200 Subject: [PATCH] Fix getallheaders function polyfill to respect proper X-GitHub-* headers casing --- deploy.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deploy.php b/deploy.php index a877fd1..722956f 100644 --- a/deploy.php +++ b/deploy.php @@ -205,9 +205,18 @@ function endScript($msg = "",$display = false) { if (!function_exists('getallheaders')) { function getallheaders() { $headers = []; + if (isset($_SERVER['CONTENT_TYPE'])) + $headers['Content-Type'] = $_SERVER['CONTENT_TYPE']; + if (isset($_SERVER['CONTENT_LENGTH'])) + $headers['Content-Length'] = $_SERVER['CONTENT_LENGTH']; foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { - $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; + $name = substr($name, 5); + $name = str_replace('_', ' ', $name); + $name = ucwords(strtolower($name)); + $name = str_replace(' ', '-', $name); + $name = str_replace('X-Github', 'X-GitHub', $name); + $headers[$name] = $value; } } return $headers;