Method/program for sending a given HTTP request (w

2019-08-24 15:53发布

问题:

I am debugging my website. When it has an error, the full text form of the HTTP request that caused the error is logged. I want to be able to replay these HTTP requests to help debugging the error.

For instance, I have this in my log now:

POST /ipn/handler.ashx?inst=272&msgType=result HTTP/1.0
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Host: mysite.com
Content-Length: 28
User-Agent: AGENT/1.0 (UserAgent)

region=website&compName=ACTL

I want a way to make this exact request again on my local test machine (with changed Host attribute). What is the best way to do this?

回答1:

You could use telnet to talk to your web server and type the exact requests.

You could also use libcurl (& curl) to make a program which is an HTTP client.

And many scripting languages (Python, Ruby, Perl, Ocaml, ...) also have HTTP client libraries (sometimes above Curl).