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
Single line:
echo '{"mydummy": "json"}' | gzip | curl -v -i --data-binary @- -H "Content-Encoding: gzip" http://localhost/mymodule
The thing is that mod_deflate does not like the gzip header shown here:
hexdump -C body.gz
00000000 1f 8b 08 08 20 08 30 59 00 03 62 6f 64 79 00 ab |.... .0Y..body..|
00000010 56 50 ca ad 4c 29 cd cd ad 54 52 b0 52 50 ca 2a |VP..L)...TR.RP.*|
00000020 ce cf 53 52 a8 e5 02 00 a6 6a 24 99 17 00 00 00 |..SR.....j$.....|
00000030
The solution is simply to give it to gzip without the intermediate file step, if taking a stream, it will not print the headers and apache will like the body!
echo '{ "mydummy" : "json" }' | gzip > body.gz
curl -v -i http://localhost/mymodule -H'Content-Encoding: gzip' --data-binary @body.gz
This works, the apache module receives the decompressed bytes.
You can see the header difference here, you no longer see the file name (body) in the gzip file:
hexdump -C body.gz
00000000 1f 8b 08 00 08 0a 30 59 00 03 ab 56 50 ca ad 4c |......0Y...VP..L|
00000010 29 cd cd ad 54 52 b0 52 50 ca 2a ce cf 53 52 a8 |)...TR.RP.*..SR.|
00000020 e5 02 00 a6 6a 24 99 17 00 00 00 |....j$.....|
0000002b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With