Page 528 - Beginning PHP 5.3
P. 528
Part III: Using PHP in Practice
Header Description Example
Cookie An HTTP cookie previously sent by this Cookie: name=fred
server (see Chapter 10 for more on
cookies).
Host This is the only mandatory header, and Host: www.example.com
then only if making an HTTP/1.1
request. Because most Web server
applications can serve Web sites at
multiple domains on a single machine,
the browser sends a Host header to tell
the server which Web site it ’ s requesting
the resource from.
Referer When a visitor clicks a link to view a Referer: www.example.
new page, most browsers send the URL com
of the page containing the link in the
Referer header. The Referer URL is
often logged by the Web server along
with the URL of the page requested.
That way, the Webmaster can look
through the server logs to see where
their visitors are coming from.
User - Agent Information about the browser, such as User - Agent: Mozilla/5.0
its type and version. (You learned how (Macintosh; U; Intel
to access this information in Chapter 15.) Mac OS X 10.5; en - GB;
rv:1.9.0.5)
Gecko/2008120121
Firefox/3.0.5
So a complete browser request (assuming there ’ s no request body) might look like this:
GET /about/index.php HTTP/1.1
Host: www.example.com
Accept: text/html, application/xml
Accept-Charset: ISO-8859-1,utf-8
Accept-Encoding: gzip,deflate
Accept-Language: en-gb,en
Cookie: name=fred
Referer: www.example.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB;
rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5
Exploring HTTP Responses
When the Web server receives an HTTP request from the browser, it sends back an HTTP response.
Typically this includes the content that the browser requested, along with some information about the
content, but it may instead return an error (if the content couldn ’ t be found, for example).
490
9/21/09 9:15:36 AM
c16.indd 490
c16.indd 490 9/21/09 9:15:36 AM