curl command a gzipped POST body to an apache server

Viewed 17971

With mod_deflate properly activated on my apache 2.2 server, I am trying to send a gzipped body via curl command line.

All tutorials I have seen say to add -H'Content-Encoding: gzip' and gzip my body file, however this fails:

echo '{ "mydummy" : "json" }' > body
gzip body
curl -v -i http://localhost/mymodule -H'Content-Encoding: gzip' --data-binary @body.gz 

My apache module receives 0 bytes

And in my apache error.log if LogLevel is set to debug I get:
[Thu Jun 01 14:29:03 2017] [debug] mod_deflate.c(900): [client 127.0.0.1] Failed to inflate input: cannot handle deflate flags

2 Answers

Single line:

echo '{"mydummy": "json"}' | gzip | curl -v -i --data-binary @- -H "Content-Encoding: gzip" http://localhost/mymodule
Related