Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm learning about the HTTP protocol and I'd like to know if there's a tool I can use to input a HTTP request I have created myself that will output the raw response. I've had a look at cURL and wget but they don't seem to have an obvious option to do this. For example:

$ http_response < my_http_request.txt
HTTP/1.0 200 OK
Date: Sat, 24 Jul 2010 18:43:58 GMT
etc..
share|improve this question

3 Answers 3

up vote 8 down vote accepted

Many people will recommend telnet for this, and it works, but I prefer to use netcat. The reason is that telnet was designed to work with a particular protocol, the TELNET protocol (which I'm not even sure anyone uses anymore...), so it's got all sorts of bells and whistles (i.e. it recognizes a whole bunch of options and commands and escape characters) that are completely irrelevant for HTTP. On the other hand, netcat simply takes its standard input and sends it out, byte-for-byte, over the network. Nothing more. That's exactly what you need to send a raw HTTP request.

There are various versions of netcat but generally their usage is the same as telnet:

netcat host port < my_http_request.txt

(on my computer the program name is nc6 rather than netcat, so substitute as appropriate)

share|improve this answer
    
It can also be called nc. –  Dennis Williamson Jul 24 '10 at 18:52
    
Good point, I just wanted to make the point that there are different names so Ross would know to actually check the filename in whatever version of netcat he installs, rather than just using "netcat" without thinking. –  David Z Jul 24 '10 at 19:20
    
I see this answer everywhere but it does not work for chunked encoding. I'm tearing my hair out here ... why does everybody use this and nobody realise that you do not actually get the proper raw response in all cases??!! –  sillyMunky Jan 9 at 22:42

It's very simple. Just use telnet over port 80. telnet www.example.com 80 < your_http_request.txt

share|improve this answer

I have used the stand-alone version of WebScarab with success.
I had less success with the Java Web Start version, although it might work for you.

WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols. It is written in Java, and is thus portable to many platforms. WebScarab has several modes of operation, implemented by a number of plugins. In its most common usage, WebScarab operates as an intercepting proxy, allowing the operator to review and modify requests created by the browser before they are sent to the server, and to review and modify responses returned from the server before they are received by the browser. WebScarab is able to intercept both HTTP and HTTPS communication. The operator can also review the conversations (requests and responses) that have passed through WebScarab.

image

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.