3

I'm trying to use port 80 to connect to a website(www.ucf.edu), and send a GET request, but I'm getting inconsistent results to other students using the same exact methods. We had to use SSH to connect securely to our schools server before doing this. When connected, we're instructed to send a get request "GET /index.html HTTP/1.1" when I send this I get inconsistent results.

I've tried using Putty on windows, and command prompt of ubuntu on a virtual machine, to no avail.

Expected Result:

telnet www.ucf.edu 80

Trying 10.171.52.44

Connected to www.ucf.edu.

Escape character is '^]'.

GET /index.html HTTP/1.1\r\n

HTTP/1.1 302 Found

Server: Apache

Location: https://www.ucf.edu/index.html

etc. etc.

Actual Result:

telnet www.ucf.edu 80

Trying 52.5.147.12...

Connected to edums-dr-alb-211439321.us-east-1.elb.amazonaws.com.

Escape character is '^]'.

GET /index.html HTTP/1.1\r\n

HTTP/1.1 400 Bad Request

Server: awselb/2.0

Date: Thu, 03 Oct 2019 05:49:42 GMT

  • 1
    I like that your school teaches you this very useful HTTP network basics! – Arjan Oct 3 '19 at 22:29
3

You are getting 400 Bad Request because it is actually a bad request.

The HTTP/1.1 request needs at least the Host: <URL> specification in the next line. It is because when you connect to that particular IP address, that particular physical server might be serving multiple domains; and if you don't specify it, the server doesn't know which domain you request. So the correct request goes like:

GET /index.html HTTP/1.1
Host: www.ucf.edu

(followed by empty line), and the whole session looks like:

artax:~> telnet www.ucf.edu 80
Trying 52.5.147.12...
Connected to educms-dr-alb-211439321.us-east-1.elb.amazonaws.com.
Escape character is '^]'.
GET /index.html HTTP/1.1
Host: www.ucf.edu

HTTP/1.1 301 Moved Permanently
Date: Fri, 04 Oct 2019 07:44:49 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Length: 238
Connection: keep-alive
Server: Apache
Location: https://www.ucf.edu/index.html
Accept-Ranges: bytes
X-Varnish: 2087970732
Age: 0
Via: 1.1 varnish
X-Cache: MISS
X-Varnish-Server: DR-VLAMP-4

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.ucf.edu/index.html">here</a>.</p>
</body></html>
Connection closed by foreign host.
  • Right, that's also part of the answer! As an aside: the 301 Moved Permanently redirects to the HTTPS version. When using HTTPS one will eventually get a 404 Not Found as the public server does not seem to know index.html at all. But doing HTTPS with Telnet is quite a challenge ;-) – Arjan Oct 4 '19 at 8:14
  • @Arjan yeah, exactly :-D – Tomas Oct 4 '19 at 12:11
6

For you www.ucf.edu resolves to a different IP-address (public internet instead of a private 10.xx.xx.xx address). And obviously that is a different server.

You mentioned that you had to login with SSH to a school server first. I presume that you are supposed to run the telnet command from within that SSH session while connected to the school server (and in that case you don't get the real www.ucf.edu on the internet but a test-environment that uses the 10.xx.xx.xx private address).

However you mentioned you get same results from Windows and Linux so I can only presume you are NOT logged in to the SSH server when you do this. (If you were connected to the SSH the client OS wouldn't make any difference.) Or you did login, but logged out again which you shouldn't have done.

So you better check the instructions carefully. Because I'm fairly sure you missed a step along the way. Or took a step too many.

  • 2
    Also note that 10.171.52.44 is a private use IP address, for use in private networks, while 52.5.147.12 is a public IP address. – Arjan Oct 3 '19 at 22:21
  • @Arjan You're right and I noticed that too, but I forgot to include that in my answer. Will edit it in as that makes the answer clearer. – Tonny Oct 4 '19 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.