diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-03-11 16:05:15 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-03-11 22:45:26 +0100 |
commit | 7098f9fe3a54eae536139fed4dd320181bab6c7c (patch) | |
tree | a15a18d9a824cbb7f37abc02a154776a8c360c43 /lib | |
parent | 4c0206f90bd0e15acc1031c2011d8a8903d2c911 (diff) | |
download | curl-7098f9fe3a54eae536139fed4dd320181bab6c7c.tar.gz |
c-hyper: support automatic content-encoding
Closes #6727
Diffstat (limited to 'lib')
-rw-r--r-- | lib/c-hyper.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/c-hyper.c b/lib/c-hyper.c index c3a16cf82..3238ceed1 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -51,6 +51,7 @@ #include "transfer.h" #include "multiif.h" #include "progress.h" +#include "content_encoding.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" @@ -175,7 +176,11 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk) if(k->ignorebody) return HYPER_ITER_CONTINUE; Curl_debug(data, CURLINFO_DATA_IN, buf, len); - result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len); + if(!data->set.http_ce_skip && k->writer_stack) + /* content-encoded data */ + result = Curl_unencode_write(data, k->writer_stack, buf, len); + else + result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len); if(result) { data->state.hresult = result; @@ -813,6 +818,19 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) goto error; } + if(!Curl_checkheaders(data, "Accept-Encoding") && + data->set.str[STRING_ENCODING]) { + Curl_safefree(data->state.aptr.accept_encoding); + data->state.aptr.accept_encoding = + aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]); + if(!data->state.aptr.accept_encoding) + return CURLE_OUT_OF_MEMORY; + if(Curl_hyper_header(data, headers, data->state.aptr.accept_encoding)) + goto error; + } + else + Curl_safefree(data->state.aptr.accept_encoding); + result = cookies(data, conn, headers); if(result) return result; |