mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 02:02:40 +01:00
Allow HTTPFuture callers to disable processing of "Content-Encoding" response headers
Summary: Ref T13507. In Phabricator, we perform a specific "Accept-Encoding: gzip" setup test and want to manually decode the result. Allow callers to disable handling of "Content-Encoding". Test Plan: Ran all Phabricator setup checks. Maniphest Tasks: T13507 Differential Revision: https://secure.phabricator.com/D21121
This commit is contained in:
parent
377ed2ed8d
commit
68f050bd14
1 changed files with 29 additions and 18 deletions
|
@ -26,7 +26,7 @@ abstract class BaseHTTPFuture extends Future {
|
||||||
private $uri;
|
private $uri;
|
||||||
private $data;
|
private $data;
|
||||||
private $expect;
|
private $expect;
|
||||||
|
private $disableContentDecoding;
|
||||||
|
|
||||||
/* -( Creating a New Request )--------------------------------------------- */
|
/* -( Creating a New Request )--------------------------------------------- */
|
||||||
|
|
||||||
|
@ -276,6 +276,15 @@ abstract class BaseHTTPFuture extends Future {
|
||||||
return strlen(phutil_build_http_querystring($data));
|
return strlen(phutil_build_http_querystring($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDisableContentDecoding($disable_decoding) {
|
||||||
|
$this->disableContentDecoding = $disable_decoding;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisableContentDecoding() {
|
||||||
|
return $this->disableContentDecoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Resolving the Request )---------------------------------------------- */
|
/* -( Resolving the Request )---------------------------------------------- */
|
||||||
|
|
||||||
|
@ -348,24 +357,26 @@ abstract class BaseHTTPFuture extends Future {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$content_encoding = null;
|
if (!$this->getDisableContentDecoding()) {
|
||||||
foreach ($headers as $header) {
|
$content_encoding = null;
|
||||||
list($name, $value) = $header;
|
foreach ($headers as $header) {
|
||||||
$name = phutil_utf8_strtolower($name);
|
list($name, $value) = $header;
|
||||||
if (!strcasecmp($name, 'Content-Encoding')) {
|
$name = phutil_utf8_strtolower($name);
|
||||||
$content_encoding = $value;
|
if (!strcasecmp($name, 'Content-Encoding')) {
|
||||||
break;
|
$content_encoding = $value;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
switch ($content_encoding) {
|
|
||||||
case 'gzip':
|
|
||||||
$decoded_body = gzdecode($body);
|
|
||||||
if ($decoded_body === false) {
|
|
||||||
return $this->buildMalformedResult($raw_response);
|
|
||||||
}
|
}
|
||||||
$body = $decoded_body;
|
}
|
||||||
break;
|
|
||||||
|
switch ($content_encoding) {
|
||||||
|
case 'gzip':
|
||||||
|
$decoded_body = @gzdecode($body);
|
||||||
|
if ($decoded_body === false) {
|
||||||
|
return $this->buildMalformedResult($raw_response);
|
||||||
|
}
|
||||||
|
$body = $decoded_body;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = new HTTPFutureHTTPResponseStatus(
|
$status = new HTTPFutureHTTPResponseStatus(
|
||||||
|
|
Loading…
Reference in a new issue