1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 00:28:48 -05:00

c-hyper: support automatic content-encoding

Closes #6727
This commit is contained in:
Daniel Stenberg 2021-03-11 16:05:15 +01:00
parent 4c0206f90b
commit 7098f9fe3a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -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,6 +176,10 @@ 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);
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) {
@ -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;