Skip to content

Commit 2336726

Browse files
author
epriestley
committed
Strip "Transfer-Encoding" headers from proxied HTTP responses
This is a likely fix for HTTP clones against proxied repositories in the cluster, although I'm not 100% sure I'm replicating it correctly. The issue appears to be that we're proxying all the headers, including the "Transfer-Encoding" header, although the request will already have stripped any encoding. This might cause us to emit a "chunked" header without a chunked body. Auditors: chad
1 parent 449da36 commit 2336726

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/aphront/response/AphrontHTTPProxyResponse.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ private function readRequest() {
5757

5858
list($status, $body, $headers) = $this->future->resolve();
5959
$this->httpCode = $status->getStatusCode();
60+
61+
// Strip "Transfer-Encoding" headers. Particularly, the server we proxied
62+
// may have chunked the response, but cURL will already have un-chunked it.
63+
// If we emit the header and unchunked data, the response becomes invalid.
64+
foreach ($headers as $key => $header) {
65+
list($header_head, $header_body) = $header;
66+
$header_head = phutil_utf8_strtolower($header_head);
67+
switch ($header_head) {
68+
case 'transfer-encoding':
69+
unset($headers[$key]);
70+
break;
71+
}
72+
}
73+
6074
$this->headers = $headers;
6175

6276
return $body;

0 commit comments

Comments
 (0)