Skip to content

Commit 997460f

Browse files
author
epriestley
committedApr 9, 2016
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.
1 parent 57e606b commit 997460f

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed
 

‎src/aphront/AphrontRequest.php

+19-7
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,26 @@ public function newClusterProxyFuture($uri) {
754754
// NOTE: apache_request_headers() might provide a nicer way to do this,
755755
// but isn't available under FCGI until PHP 5.4.0.
756756
foreach ($_SERVER as $key => $value) {
757-
if (preg_match('/^HTTP_/', $key)) {
758-
// Unmangle the header as best we can.
759-
$key = substr($key, strlen('HTTP_'));
760-
$key = str_replace('_', ' ', $key);
761-
$key = strtolower($key);
762-
$key = ucwords($key);
763-
$key = str_replace(' ', '-', $key);
757+
if (!preg_match('/^HTTP_/', $key)) {
758+
continue;
759+
}
760+
761+
// Unmangle the header as best we can.
762+
$key = substr($key, strlen('HTTP_'));
763+
$key = str_replace('_', ' ', $key);
764+
$key = strtolower($key);
765+
$key = ucwords($key);
766+
$key = str_replace(' ', '-', $key);
767+
768+
// By default, do not forward headers.
769+
$should_forward = false;
770+
771+
// Forward "X-Hgarg-..." headers.
772+
if (preg_match('/^X-Hgarg-/', $key)) {
773+
$should_forward = true;
774+
}
764775

776+
if ($should_forward) {
765777
$headers[] = array($key, $value);
766778
$seen[$key] = true;
767779
}

0 commit comments

Comments
 (0)
Failed to load comments.