learn more...The HTTP protocol can be likened to a conversation based on a series of questions and answers, which we refer to respectively as HTTP requests and HTTP responses. The contents of HTTP requests and responses are easy to read and understand, being near to plain English in their syntax. This section examines the structure of these requests and responses, along with a few examples of the sorts of data they may contain. The HTTP RequestAfter opening a connection to the intended server, the HTTP client transmits a request in the following format:
The opening line is generally split into three parts; the name of the method, the path to the required server resource, and the HTTP version being used. A typical opening line might read: GET /test/testpage.html HTTP/1.0In this line we are telling the server that we are sending an HTTP request of type GET (explained more fully in the next section), we are sending this using HTTP version 1.0, and the server resource we require (including its local path) is /test/testpage.htmlHeader lines are used to send information about the request, or about the data being sent in the message body. One parameter and value pair is sent per line, the parameter and value being separated by a colon. Here's an example: User-Agent: [name of program sending request]For instance, Internet Explorer v5.5 offers something like the following: User-agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)A further example of a common request header is the Accept: header, which states what sort(s) of information will be found acceptable as a response from the server: Accept: text/plain, text/htmlBy issuing the header in the preceding example, the request is informing the server that the sending application can accept either plain text or HTML responses (that is, it is not equipped to deal with, say, an audio or video file). The HTTP ResponseIn answer to such a request, the server typically issues an HTTP response, the first line of which is often referred to as the status line. In that line the server echoes the HTTP version and gives a response status code (which is a three-digit integer) and a short message known as a reason phrase. Here's an example HTTP response: HTTP/1.0 200 OKThe response status code and reason phrase are essentially intended as machine-and human-readable versions of the same message, though the reason phrase may actually vary a little from server to server.The table below lists some examples of common status codes and reason phrases. The first digit of the status code usually gives some clue about the nature of the message:
The response may also contain header lines each containing a header and value pair similar to those of the HTTP request but generally containing information about the server and/or the resource being returned: Server: Apache/1.3.22 Last-Modified: Fri, 24 Dec 1999 13:33:59 GMT |
||||||||||||||||||||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |