curl / Mailing Lists / curl-library / Single Mail


Range + gzip Encoding = 0 byte body

From: Rainer Canavan <>
Date: Wed, 26 Apr 2017 15:24:43 +0200


we're trying to pass (some) incoming requests to another server using
libcurl and the corresponding response back to the client, i.e.
basically like a proxy.

For Requests with non-trivial Range:-Headers, and Accept-Encoding, if
the server does indeed uses gzip or compressed encoding, curl fails to
decompress the body because it is incomplete, and returns no content.
As far as I can see, no error is raised, and the request appears to be
successful. This can easily be reproduced with the trivial change to
examples/getinmemory.c shown below. I'm not sure what a correct
behavior for curl would be, i.e. flag this as an error, pass the "raw"
response body, or something completely different. I believe using
CURLOPT_DEBUGFUNCTION to extract the body would be an appropriate

Other people have stumbled across this in the past, e.g.,209738,209850


diff --git a/docs/examples/getinmemory.c b/docs/examples/getinmemory.c
index fb79478..cb158f9 100644
--- a/docs/examples/getinmemory.c
+++ b/docs/examples/getinmemory.c
@@ -72,7 +72,9 @@ int main(void)
  curl_handle = curl_easy_init();

  /* specify URL to get */
- curl_easy_setopt(curl_handle, CURLOPT_URL, "");
+ curl_easy_setopt(curl_handle, CURLOPT_URL, "");
+ curl_easy_setopt(curl_handle, CURLOPT_ACCEPT_ENCODING, "");
+ curl_easy_setopt(curl_handle, CURLOPT_RANGE, "0-10");

  /* send all data to this function */
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
Received on 2017-04-26