1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

When proxying HTTP repository responses from repository nodes, discard content description headers

Summary:
Ref T13517. See that task for details about the underlying issue here.

Currently, we may decode a compressed response, then retransmit it with leftover "Content-Encoding" and "Content-Length" headers. Instead, strip these headers.

Test Plan:
  - In a clustered repository setup, cloned a Git repository over HTTP.
  - Before: Error while processing content unencoding: invalid stored block lengths
  - After: Clean clone.

Maniphest Tasks: T13517

Differential Revision: https://secure.phabricator.com/D21167
This commit is contained in:
epriestley 2020-04-25 07:30:25 -07:00
parent 6f7147376f
commit 454ecb56e3

View file

@ -61,11 +61,17 @@ final class AphrontHTTPProxyResponse extends AphrontResponse {
// Strip "Transfer-Encoding" headers. Particularly, the server we proxied // Strip "Transfer-Encoding" headers. Particularly, the server we proxied
// may have chunked the response, but cURL will already have un-chunked it. // 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. // If we emit the header and unchunked data, the response becomes invalid.
// See T13517. Strip "Content-Encoding" and "Content-Length" headers, since
// they may reflect compressed content.
foreach ($headers as $key => $header) { foreach ($headers as $key => $header) {
list($header_head, $header_body) = $header; list($header_head, $header_body) = $header;
$header_head = phutil_utf8_strtolower($header_head); $header_head = phutil_utf8_strtolower($header_head);
switch ($header_head) { switch ($header_head) {
case 'transfer-encoding': case 'transfer-encoding':
case 'content-encoding':
case 'content-length':
unset($headers[$key]); unset($headers[$key]);
break; break;
} }