Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a tool (possibly on Linux) that will allow me to make a manual HTTP or HTTPS request. By manual, I really mean it: I should be able to feed it a text file which looks like

POST /foo HTTP/1.1
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Content-Type: text/plain
Content-Length: 11

Hello world

and a destination URL (, and send the request to the URL. At most, it would be useful if the Content_Length header was automatically computed.

I would be able to write such a tool using some library like httplib in Python, but the very reason I need it is to do manual investigation when something goes wrong with such libraries.

share|improve this question
up vote 9 down vote accepted

wget has a --post-file option which should work for you.

Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:

ncat -C --ssl 443 < input.txt > output.txt
share|improve this answer
+1 because this is probably the best solution. – Randolf Richardson Jul 18 '11 at 20:54
If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443 – Ambroz Bizjak Jul 18 '11 at 22:24

For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:

  • telnet hostname 80 < input.txt > output.txt

The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.

share|improve this answer
This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone. – Chris Acheson Jul 18 '11 at 22:15
@Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this). – Randolf Richardson Jul 18 '11 at 22:38

I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).

So for your example all you would do is:

curl -H 'Content-Type: text/plain' -d 'Hello World'

Which captured from Wireshark will net you:

User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/ libidn/1.15
Accept: */*
Content-Type: text/plain
Content-Length: 11

Hello world

You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).

Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol

-d @/tmp/HelloWorldFile
share|improve this answer
curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-) – Andrea Jul 21 '11 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .