The problem is using HTTP 1.0 on a server that requires HTTP 1.1 (and the Host:
header that is a mandatory part of HTTP 1.1), probably because it is probably doing virtual hosting of multiple websites on one IP address. Or maybe it is behind an HTTP load balancer or reverse proxy that is basically doing the same thing: supporting multiple separate web server domain names behind one IP address and port.
This works for me:
$ telnet www.httpbin.org 80
Trying 23.23.171.5...
Connected to www.httpbin.org.herokudns.com.
Escape character is '^]'.
GET /ip HTTP/1.1
Host: www.httpbin.org
…and I get back…
HTTP/1.1 200 OK
Connection: keep-alive
Server: meinheld/0.6.1
Date: Tue, 09 Jan 2018 22:01:19 GMT
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
X-Processed-Time: 0.000454902648926
Content-Length: 32
Via: 1.1 vegur
{
"origin": "[My IPv4 address redacted]"
}
^]
telnet> close
$
Note that the connection stayed open and I had to escape to the telnet>
prompt to close. I could have avoided that by adding a Connection: close
header to my request.
If you try HTTP/1.1 with a Host:
header and it still doesn't work for you, make sure your telnet client is sending CRLFs and not just carriage returns or linefeeds. Make sure you end your request with an extra CRLF after the last line.
CRLF is crucial here. I didn't need to use the User-Agent header. – pbies – 2018-10-24T06:10:57.577