简体   繁体   中英

Process raw HTTP request

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 cat raw.http | curl but without success.

Any suggestion?

Thx.

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

The question is tagged curl so I thought it was about time there was a curl answer

cat raw.http | curl "telnet://TARGETHOST:80"

For normal use just need to set the TARGETHOST to be the same as "host" header value.

For my purposes(not normal) I was hitting a TARGETHOST that was an ip address with a server that was listening for host headers of specific hosts.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM