Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process raw HTTP request

Tags:

I'd like to pass a raw HTTP request like:

GET /foo/bar HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; fr; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Accept: */* Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Content-Type: application/x-www-form-urlencoded X-Requested-With: XMLHttpRequest Referer: http://example.org/test Cookie: foo=bar; lorem=ipsum; 

to a HTTP client.

I tried cat raw.http | curl but without success.

Any suggestion?

Thx.

like image 949
abernier Avatar asked Sep 01 '10 17:09

abernier


People also ask

What is raw HTTP request?

The Raw HTTP action sends a HTTP request to a web server. How the response is treated depends on the method, but in general the status code and the response headers are returned in variables defined as part of the page load options.

How do I see raw HTTP requests?

In Chrome CTRL + SHIFT + C to launch Chrome Console. From there select Network Tab; There you can see the POST Request details and form data.

What is a raw HTTP header?

Raw means that the header is not URL-encoded, whereas if the word "raw" is omitted, the header is encoded. For example: $header = 'http://www.mywebsite.com?

Which of the following are parts of a raw HTTP request?

An HTTP request is divided into three parts: Request line, header and body. An HTTP response is also divided into three parts: Status line, header and body.


2 Answers

Raw data in, raw data out:

nc example.org 80 < raw.http 

If you need to pipe the data through some program:

cat raw.http | someprogram | nc example.org 80 

Manual page

like image 52
Lekensteyn Avatar answered Nov 07 '22 01:11

Lekensteyn


Note that neither of these solutions would work if your need httpS instead of http. In this case you can send it this way:

$ cat raw.http | openssl s_client -connect server:443 
like image 44
ffeast Avatar answered Nov 07 '22 02:11

ffeast