1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

(stable) 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
This commit is contained in:
epriestley 2016-01-07 16:33:09 -08:00
parent 571960e712
commit 70079f47db

View file

@ -57,6 +57,20 @@ final class AphrontHTTPProxyResponse extends AphrontResponse {
list($status, $body, $headers) = $this->future->resolve(); list($status, $body, $headers) = $this->future->resolve();
$this->httpCode = $status->getStatusCode(); $this->httpCode = $status->getStatusCode();
// Strip "Transfer-Encoding" headers. Particularly, the server we proxied
// may have chunked the response, but cURL will already have un-chunked it.
// If we emit the header and unchunked data, the response becomes invalid.
foreach ($headers as $key => $header) {
list($header_head, $header_body) = $header;
$header_head = phutil_utf8_strtolower($header_head);
switch ($header_head) {
case 'transfer-encoding':
unset($headers[$key]);
break;
}
}
$this->headers = $headers; $this->headers = $headers;
return $body; return $body;