1.4. What the Client Does
The browser observes that the URL starts with http: and deduces that it should be using the HTTP protocol. The "//" says that the URL is absolute, that is, not relative to some other URL. The next part must be the name of the server, www.apache.org. The client then contacts a name server, which uses DNS to resolve this name to an IP address. At the time of writing, this address was 184.108.40.206. One way to check the validity of a hostname is to go to the operating-system prompt and type:
> ping -c 5 www.apache.org
% ping -c 5 www.apache.org
If that host is connected to the Internet, a response is returned:
PING www.apache.org (220.127.116.11): 56 data bytes 64 bytes from taz.apache.org (18.104.22.168): icmp_seq=0 ttl=247 time=1380 ms 64 bytes from taz.apache.org (22.214.171.124): icmp_seq=1 ttl=247 time=1930 ms 64 bytes from taz.apache.org (126.96.36.199): icmp_seq=2 ttl=247 time=1380 ms 64 bytes from taz.apache.org (188.8.131.52): icmp_seq=3 ttl=247 time=1230 ms 64 bytes from taz.apache.org (184.108.40.206): icmp_seq=4 ttl=247 time=1360 ms --- www.apache.org ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/ max = 1230/1456/1930 ms
The web address http://www.apache.org doesn't include a port because it is port 80, the default, and the browser takes it for granted. If some other port is wanted, it is included in the URL after a colon -- for example, http://www.apache.org:8000/. The URL always includes a path, even if is only "/". If the path is left out by the careless user, most browsers put it back in. If the path were /some/where/foo.html on port 8000, the URL would be http://www.apache.org:8000/some/where/foo.html.
The client now makes a TCP connection to port number 8000 on IP 220.127.116.11, and sends the following message down the connection (if it is using HTTP/1.0):
GET /some/where/foo.html HTTP/1.0<CR><LF><CR><LF>
These carriage returns and line feeds (CRLF) are very important because they separate the HTML header from its body. If the request were a POST, there would be data following. The server sends the response back and closes the connection. To see it in action, connect again to the Internet, get a command-line prompt, and type the following:
% telnet www.apache.org 80
> telnet www.apache.org 80
Since telnet also requires CRLF as the end of every line, it sends the right thing for you when you hit the Return key. Some implementations of telnet rather unnervingly don't echo what you type to the screen, so it seems that nothing is happening. Nevertheless, a whole mess of response streams past:
GET /announcelist.html HTTP/1.0 HTTP/1.1 200 OK Date: Sun, 15 Dec 1996 13:45:40 GMT Server: Apache/1.3 Connection: close Content-Type: text/html Set-Cookie: Apache=arachnet784985065755545; path=/ <HTML> <HEAD> <TITLE>Join the Apache-Users Mailing List</TITLE> </HEAD> <BODY> <IMG SRC="images/apache_sub.gif" ALT=""> <H1>Join the Apache-Announce Mailing List</H1> <P> The <code>apache-announce</code> mailing list has been set up to inform people of new code releases, bug fixes, security fixes, and general news and information about the Apache server. Most of this information will also be posted to comp.infosystems.www.servers.unix, but this provides a more timely way of accessing that information. The mailing list is one-way, announcements only. <P> To subscribe, send a message to <code><b>email@example.com</b></code> with the words "subscribe apache-announce" in the body of the message. Nope, we don't have a web form for this because frankly we don't trust people to put the right address. <img src="images/smiley.xbm"> <A HREF="index"><IMG SRC="images/apache_home.gif" ALT="Home"></A> </BODY></HTML> Connection closed by foreign host.
Copyright © 2001 O'Reilly & Associates. All rights reserved.