Send a Compressed Request

curl can be used to send a compressed HTTP request - HTTP requests are not usually compressed, only the responses are, but the standard does not prohibit setting the Content-Encoding header to gzip, deflate or others and then sending a compressed body.

To send a compressed POST HTTP request, first create a file containing the body that shall be sent, say, request.txt and then compress the file using gzip:

gzip request.txt

For this example, the request.txt file contains POST key-value data such that the request content type will be set to application/x-www-url-form-urlencoded.

The command will create a compressed file request.txt.gz. Afterward, the curl command shall read:

curl -v --data-binary @request.txt.gz "Content-Type: application/x-www-url-form-urlencoded" -H "Content-Encoding: gzip" -X POST http://server.tld/

where:

  • -v turns on verbosity,
  • –data-binary @request.txt.gz will send the request.txt.gz file as the request body (mind the @, it is necessary),
  • the request Content-Type is set to application/x-www-url-form-urlencoded indicating that the request.txt.gz file contains POST key-value data,
  • the request Content-Encoding is set to gzip,
  • the request will be sent to http://server.tld/

fuss/curl.txt · Last modified: 2018/06/14 19:48 by office

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.