New Perspectives On Web Design

(C. Jardin) #1
By Paul Tero CHAPTER 8

Speaking HTTP
At this stage, your Web server software is hopefully up and running. If
it did crash, you’ve restarted it, found out the reason and taken steps to
prevent it from happening again.
You can now double-check your Web server is up and running by
telnetting to port 80 from your laptop again. This time it should say
“Connected” and then wait for your request. Web servers understand
HTTP (hypertext transfer protocol). After a connection is established type
GET / HTTP/1.1 to tell the server you would like to GET (as opposed to
POST) the home page / and that you speak version 1.1 of the protocol.
Press Enter and then type Host: followed by the host name. This line is
only necessary on servers which host more than one website. HTTP does
not know that you telnetted to http://www.smashingmagazine.com. As far as it is
concerned, you telnetted to 80.72.139.101 and it needs to know which of its
many websites you are interested in. Press Enter twice to make the request.
You should get back a long stream of text and HTML:


$ telnet http://www.smashingmagazine.com 80
Trying 80.72.139.101...
Connected to http://www.smashingmagazine.com.
Escape character is '^]'.
GET / HTTP/1.1
Host: http://www.smashingmagazine.com


HTTP/1.1 200 OK
Date: Thu, 09 May 2013 13:25:52 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.2.17
Content-Length: 25023
Content-Type: text/html



<...
Free download pdf