From e1945965e8c89027216b3b3dec2e0c6fa194b867 Mon Sep 17 00:00:00 2001
From: Fabian Frank <fabian@pagefault.de>
Date: Wed, 5 Feb 2014 00:21:16 -0800
Subject: [PATCH] http2: rely on content-encoding header

A server might respond with a content-encoding header and a response
that was encoded accordingly in HTTP-draft-09/2.0 mode, even if the
client did not send an accept-encoding header earlier. The server
might not send a content-encoding header if the identity encoding was
used to encode the response.

See:
http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-9.3
---
 lib/http.c  | 3 ++-
 lib/http2.c | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/http.c b/lib/http.c
index 2ea6f7e..c1125f2 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -3402,7 +3402,8 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
 
     }
     else if(checkprefix("Content-Encoding:", k->p) &&
-            data->set.str[STRING_ENCODING]) {
+            (data->set.str[STRING_ENCODING] ||
+             data->set.httpversion == CURL_HTTP_VERSION_2_0)) {
       /*
        * Process Content-Encoding. Look for the values: identity,
        * gzip, deflate, compress, x-gzip and x-compress. x-gzip and
diff --git a/lib/http2.c b/lib/http2.c
index baf36cc..424e562 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -410,7 +410,6 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req,
   free(base64);
 
   k->upgr101 = UPGR101_REQUESTED;
-  k->auto_decoding = GZIP;
 
   return result;
 }
@@ -641,7 +640,7 @@ int Curl_http2_switched(struct connectdata *conn)
   httpc->data = NULL;
   httpc->datalen = 0;
 
-  conn->data->req.auto_decoding = GZIP;
+  conn->data->set.httpversion = CURL_HTTP_VERSION_2_0;
 
   /* Put place holder for status line */
   Curl_add_buffer(httpc->header_recvbuf, "HTTP/2.0 200\r\n", 14);
-- 
1.8.3.2

