Consider the following hyperlink:

<a href="http://www.cs.rutgers.edu/∼shklar/">

What HTTP/1.0 request will get submitted by the browser? What HTTP/1.1 request will get submitted by the browser?

Will these requests change if the browser is configured to contact an HTTP proxy? If yes, how?

有帮助吗?

解决方案

While you could use tcpdump to dump the actual network traffic, curl is surely more handy to test the HTTP conversation from the command line.

An HTTP/1.0 request:

curl -v -0 http://www.cs.rutgers.edu/∼shklar/
* About to connect() to www.cs.rutgers.edu port 80 (#0)
*   Trying 128.6.4.24...
* connected
* Connected to www.cs.rutgers.edu (128.6.4.24) port 80 (#0)
> GET /∼shklar/ HTTP/1.0
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.cs.rutgers.edu
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Wed, 31 Oct 2012 17:57:31 GMT
< Server: Apache/1.3.26 (Unix)
< Content-Type: text/html; charset=iso-8859-1
< Connection: close

An HTTP/1.1 request:

curl -v http://www.cs.rutgers.edu/∼shklar/ 
* About to connect() to www.cs.rutgers.edu port 80 (#0)
*   Trying 128.6.4.24...
* connected
* Connected to www.cs.rutgers.edu (128.6.4.24) port 80 (#0)
> GET /∼shklar/ HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.cs.rutgers.edu
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Wed, 31 Oct 2012 17:59:47 GMT
< Server: Apache/1.3.26 (Unix)
< Content-Type: text/html; charset=iso-8859-1
< Transfer-Encoding: chunked

Use the -x (or --proxy) <[protocol://][user@password]proxyhost[:port]> switch to use a proxy and see the results.

More about curl here: http://curl.haxx.se/docs/manpage.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top