Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get curl to decompress a response without sending the Accept headers in the request?

Tags:

curl

gzip

Is there any way to get curl to decompress a response without sending the Accept-encoding headers in the request?

I'm trying to debug an issue where the order of the Accept-encoding headers may be relevant, but I also need to know what the response is. If I just send -H 'Accept-encoding: gzip and the server gzips the response, curl won't decompress it.

like image 715
Jun-Dai Bates-Kobashigawa Avatar asked Sep 24 '13 13:09

Jun-Dai Bates-Kobashigawa


People also ask

What does curl compressed do?

compressed to a generated curl command so that curl decompresses the response body.

Does curl support gzip?

Curl is, without a doubt, one of the most powerful command-line tools for testing and debugging websites. It allows you to customise your HTTP request in any way you desire. To test if a website is performing Gzip compression, you can of course use curl.

What is accept-encoding deflate?

It means the client can accept a response which has been compressed using the DEFLATE algorithm.

Is accept-encoding required?

Accept-encoding header is an HTTP header which must be included on every origin server response. Its main job is to inform the browsers if the client can handle the compressed version of the website. The warning can appear when you don't use the Vary: Accept-Encoding in your header on a server or CDN.


2 Answers

Probably the easiest thing to do is just use gunzip to do it:

curl -sH 'Accept-encoding: gzip' http://example.com/ | gunzip - 

Or there's also --compressed, which curl will decompress (I believe) since it knows the response is compressed. But, not sure if that meets your needs.

like image 186
FatalError Avatar answered Sep 28 '22 09:09

FatalError


curl --compressed http://example.com requests gzipped-compressed data and uncompresses it before writing to disk.

like image 27
thakis Avatar answered Sep 28 '22 09:09

thakis