|
|
||||||||||
|
| ||||||||||
Chapter 2: Beginning PHP 4 December 18, 2000
The HTTP RequestThe browser sends the HTTP request to the web server and it contains the following: The Request Line The first line of every HTTP request is the request line, which contains three pieces of information:
GET /testpage.htm HTTP/1.1 The method is used to tell the server how to handle the request. Here are three of the most common methods that might appear in this field:
The HTTP Header The next bit of information sent is the HTTP header. This contains details of what document types the client will accept back from the server, like the type of browser that has requested the page, the date, and general configuration information. The HTTP request's header contains information that falls into three different categories:
An example HTTP header might look like this:
Accept: */* As you can see, the HTTP header is composed of a number of lines; each line contains the description of a piece of HTTP header information, and its value. There are many different lines that can comprise a HTTP header, and most of them are optional, so HTTP has to indicate when it has finished transmitting the header information. To do this, a blank line is used. In HTTP 1.1, a request must comprise of at least a request line and a HOST header. The HTTP Body If the POST method was used in the HTTP request line, then the HTTP request body will contain any data that is being sent to the server - for example, data that the user typed into an HTML form (we'll see examples of this later in the book). Otherwise, the HTTP request body will be empty. The HTTP Response The HTTP response is sent by the server back to the client browser, and contains the following. The Response Line The response line contains only two bits of information:
HTTP/1.1 200 OK This example returns the HTTP status code 200, which represents the message "OK". This denotes the success of the request, and that the response contains the required page or data from the server. You may recall that we mentioned the status code 404 a few pages ago - if the response line contains a 404 then the web server failed to find the requested resource. Error code values are three-digit numbers, where the first digit indicates the class of the response. There are five classes of response:
The HTTP Header The HTTP response header is similar to the request header, which we discussed above. In the HTTP response, the header information again falls into three types:
The first line we've already discussed, the second is self-explanatory. On the third line, "Server", indicates the type of software the web server is running, and as we are requesting a file somewhere on the web server, the last bit of information refers to the last time the page we are requesting was modified.
The header can contain much more information than this, or different information, depending on what is requested. If you want to know more about the different types of information contained in the three parts of the header, you'll find them listed in RFC 2068 (Sections 4.5, 7.1 and 7.2).
The HTTP Body
If the request was successful, then the HTTP response body contains the HTML code (together with any script that is to be executed by the browser), ready for the browser's interpretation.
| ||||||||||
|
PAGE: 1 I 2 I 3 I 4 I FIRST PAGE |
||||||||||


The HTTP Request










