With the command telnet docs.python.org 80
, I can do a manual HTTP request to http://docs.python.org/2/license.html
, by typing the actual request.
Now, instead of typing it in live, I'd like to feed the request from a text file.
I tried this:
cat request.txt|telnet docs.python.org 80
request.txt:
GET /2/license.html HTTP/1.1
Host: docs.python.org
(You have to finish the file with a blank line or you'll get a bad request!)
But the connection to the server is closed immediately.
How should I properly pipe request.txt to telnet docs.python.org 80
?
edit:
It's good to know; if you use HEAD
instead of GET
, you will get the same response as if you did a GET
request, except for the message body.
So, use HEAD
if you just want to examine the HTTP headers. (i.e. So that the contents of the response doesn't clutter your shell output.)
GET
you have posted, I get a408 Request Time-out
error. Also, iswget http://docs.python.org/2/license.html
not an option?telnet docs.python.org 80
, so you 'll have to hurry and type in those two lines(copy paste if necc.) within a few seconds or the server will return a time-out error.telnet docs.python.org 80
<ENTER>
GET /2/license.html HTTP/1.1
<ENTER>
Host: docs.python.org
<ENTER>
<ENTER>
<ENTER>
a second time at the end is because the HTTP protocol requires an extra empty line after the request headers. See the request message section of the HTTP wiki articletelnet < request.txt
but I can't get theGET
command to work.