home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeApache: The Definitive GuideSearch this book

1.4. What the Client Does

Once the server is set up, we can get down to business. The client has the easy end: it wants web action on a particular URL such as http://www.apache.org/. What happens?

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,[9] 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 One way to check the validity of a hostname is to go to the operating-system prompt[10] and type:

[9]Relevant RFCs are 1808, Relative URLs, and 1738, URLs.

[10]The operating-system prompt is likely to be ">" (Win95) or "%" (Unix). When we say, for instance, "Type % ping," we mean, "When you see `%', type `ping'."

> 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 ( 56 data bytes
64 bytes from taz.apache.org ( icmp_seq=0 ttl=247 time=1380 ms
64 bytes from taz.apache.org ( icmp_seq=1 ttl=247 time=1930 ms
64 bytes from taz.apache.org ( icmp_seq=2 ttl=247 time=1380 ms
64 bytes from taz.apache.org ( icmp_seq=3 ttl=247 time=1230 ms
64 bytes from taz.apache.org ( 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, 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=/
<TITLE>Join the Apache-Users Mailing List</TITLE>
<IMG SRC="images/apache_sub.gif" ALT="">
<H1>Join the Apache-Announce Mailing List</H1>
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.
To subscribe, send a message to
<code><b>majordomo@apache.org</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>
Connection closed by foreign host.

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.