Process raw HTTP request

后端 未结 3 478
遥遥无期
遥遥无期 2020-12-28 16:41

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         


        
相关标签:
3条回答
  • 2020-12-28 17:08

    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
    
    0 讨论(0)
  • 2020-12-28 17:26

    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.

    0 讨论(0)
  • 2020-12-28 17:28

    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

    0 讨论(0)
提交回复
热议问题