Page MenuHomePhabricator

D21118.id50294.diff
No OneTemporary

D21118.id50294.diff

diff --git a/src/future/http/BaseHTTPFuture.php b/src/future/http/BaseHTTPFuture.php
--- a/src/future/http/BaseHTTPFuture.php
+++ b/src/future/http/BaseHTTPFuture.php
@@ -348,6 +348,26 @@
}
}
+ $content_encoding = null;
+ foreach ($headers as $header) {
+ list($name, $value) = $header;
+ $name = phutil_utf8_strtolower($name);
+ if (!strcasecmp($name, 'Content-Encoding')) {
+ $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;
+ }
+
$status = new HTTPFutureHTTPResponseStatus(
$response_code,
$body,
diff --git a/src/future/http/HTTPSFuture.php b/src/future/http/HTTPSFuture.php
--- a/src/future/http/HTTPSFuture.php
+++ b/src/future/http/HTTPSFuture.php
@@ -280,12 +280,16 @@
$headers = $this->getHeaders();
$saw_expect = false;
+ $saw_accept = false;
for ($ii = 0; $ii < count($headers); $ii++) {
list($name, $value) = $headers[$ii];
$headers[$ii] = $name.': '.$value;
- if (!strncasecmp($name, 'Expect', strlen('Expect'))) {
+ if (!strcasecmp($name, 'Expect')) {
$saw_expect = true;
}
+ if (!strcasecmp($name, 'Accept-Encoding')) {
+ $saw_accept = true;
+ }
}
if (!$saw_expect) {
// cURL sends an "Expect" header by default for certain requests. While
@@ -302,6 +306,15 @@
// http://curl.haxx.se/mail/archive-2009-07/0008.html
$headers[] = 'Expect:';
}
+
+ if (!$saw_accept) {
+ if (!$use_streaming_parser) {
+ if ($this->canAcceptGzip()) {
+ $headers[] = 'Accept-Encoding: gzip';
+ }
+ }
+ }
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// Set the requested HTTP method, e.g. GET / POST / PUT.
@@ -821,4 +834,8 @@
);
}
+ private function canAcceptGzip() {
+ return function_exists('gzdecode');
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 10:51 AM (13 h, 50 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6982572
Default Alt Text
D21118.id50294.diff (2 KB)

Event Timeline