Skip to content

Commit 9691cfe

Browse files
authored
Merge pull request #19 from RunnerLee/master
格式化请求头, 将 "-" 替换为"_"
2 parents 0a49e0c + 1abfe21 commit 9691cfe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ServerRequest.php

+6
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ public static function createServerRequestFromGlobals()
519519
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
520520
$headers = function_exists('getallheaders') ? getallheaders() : [];
521521

522+
foreach ($headers as $name => $value) {
523+
unset($headers[$name]);
524+
$name = str_replace('-', '_', $name);
525+
$headers[$name] = $value;
526+
}
527+
522528
return new static($method, static::createUriFromGlobal($_SERVER), $headers, new PhpInputStream(), $_SERVER);
523529
}
524530
}

0 commit comments

Comments
 (0)