User Tools

Site Tools


tips:linux:httppost

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tips:linux:httppost [2009/06/08 08:46] – created eriktips:linux:httppost [2012/06/02 06:09] (current) erik
Line 1: Line 1:
 +====== Quickly Send a HTTP POST Request ======
  
 +Have you ever wanted to quickly send a POST request to a HTTP server? It's pretty easy to do using curl.
 +
 +For example to send XML via a POST request, you could use the following:
 +
 +  curl --header "Content-Type: text/xml" --data "<?xml version="1.0"?>...." http://www.foo.com/
 +
 +I use this method for testing almost every day. Saves a lot of time.
 +
 +Another curl command I use often is:
 +
 +  curl -I http://www.example.com/
 +
 +to get a HEAD request.
 +
 +And:
 +
 +  curl --header "Accept-Encoding: gzip" http://www.foo.com/ | gunzip
 +
 +to get the compressed request, or to verify that the request is compressed:
 +
 +  curl -I -H "Accept-Encoding: gzip,deflate" http://www.foo.com/
 +
 +You can also pipe the resulting page to vim, using:
 +
 +  curl http://www.foo.com/ | vim -
 + 
 +use:
 +
 +  curl -i http://www.foo.com/ | vim -
 +
 +to also view the headers.