3

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..

3 Answers 3

10

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)

4
  • 2
    It can also be called nc. Jul 24, 2010 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, 2010 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, 2014 at 22:42
  • 1
    cat raw_request | ncat --ssl host 443 should work for HTTPS. (ncat from nmap package because ncat supports tls while netcat doesn't)
    – noraj
    Jan 26, 2022 at 22:34
1

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

1

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

You must log in to answer this question.

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