mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
When proxying cluster HTTP requests, forward only selected headers
In the live cluster, some subset of the forwarded headers are creating some issues for HTTP repository operations.
This commit is contained in:
parent
57e606b395
commit
997460f12f
1 changed files with 19 additions and 7 deletions
|
@ -754,14 +754,26 @@ final class AphrontRequest extends Phobject {
|
||||||
// NOTE: apache_request_headers() might provide a nicer way to do this,
|
// NOTE: apache_request_headers() might provide a nicer way to do this,
|
||||||
// but isn't available under FCGI until PHP 5.4.0.
|
// but isn't available under FCGI until PHP 5.4.0.
|
||||||
foreach ($_SERVER as $key => $value) {
|
foreach ($_SERVER as $key => $value) {
|
||||||
if (preg_match('/^HTTP_/', $key)) {
|
if (!preg_match('/^HTTP_/', $key)) {
|
||||||
// Unmangle the header as best we can.
|
continue;
|
||||||
$key = substr($key, strlen('HTTP_'));
|
}
|
||||||
$key = str_replace('_', ' ', $key);
|
|
||||||
$key = strtolower($key);
|
|
||||||
$key = ucwords($key);
|
|
||||||
$key = str_replace(' ', '-', $key);
|
|
||||||
|
|
||||||
|
// Unmangle the header as best we can.
|
||||||
|
$key = substr($key, strlen('HTTP_'));
|
||||||
|
$key = str_replace('_', ' ', $key);
|
||||||
|
$key = strtolower($key);
|
||||||
|
$key = ucwords($key);
|
||||||
|
$key = str_replace(' ', '-', $key);
|
||||||
|
|
||||||
|
// By default, do not forward headers.
|
||||||
|
$should_forward = false;
|
||||||
|
|
||||||
|
// Forward "X-Hgarg-..." headers.
|
||||||
|
if (preg_match('/^X-Hgarg-/', $key)) {
|
||||||
|
$should_forward = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($should_forward) {
|
||||||
$headers[] = array($key, $value);
|
$headers[] = array($key, $value);
|
||||||
$seen[$key] = true;
|
$seen[$key] = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue