Monday, August 31, 2015

In this Post I'll explain you how to send a GZIPed post body using CURL commands. Its pretty straight forward, noting down if anyone come accross a similar requirement.

First you need to create the body you need to send, In my case I'm sending a XML content. So create a valid xml file, then zip the created file in gzip format, In ubuntu you can just right click on the file and compress it. After compressing the file will have a .gz extension.

e.g : test.xml.gz

Now navigate to the file location in terminal and execute the following command.

curl -v -s --trace-ascii http_trace.log --data-binary @test.xml.gz -H "Content-Type: text/xml" -H "Content-Encoding: gzip" -X POST

After invoking everything will be recorded in the specified log file.

== Info:   Trying
== Info: Connected to ( port 8280 (#0)
=> Send header, 155 bytes (0x9b)
0000: POST /api01 HTTP/1.1
0016: User-Agent: curl/7.35.0
002f: Host:
0048: Accept: */*
0055: Content-Type: text/xml
006d: Content-Encoding: gzip
0085: Content-Length: 42
=> Send data, 42 bytes (0x2a)
0000: .......U..test.xml..)I-.....6.`&..-..J....
== Info: upload completely sent off: 42 out of 42 bytes
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK
<= Recv header, 24 bytes (0x18)
0000: Content-Type: text/xml
<= Recv header, 37 bytes (0x25)
0000: Date: Tue, 01 Sep 2015 06:40:03 GMT
<= Recv header, 28 bytes (0x1c)
0000: Transfer-Encoding: chunked
<= Recv header, 2 bytes (0x2)
<= Recv data, 34 bytes (0x22)
0000: 17
0004: <abc>Created !!!!</abc>
001d: 0
== Info: Connection #0 to host left intact



Post a Comment

Subscribe to RSS Feed Follow me on Twitter!