The HTTP Request

After opening a connection to the intended server, the HTTP client transmits a request in the following format:

  • An opening line
  • Optionally, a number of header lines
  • A blank line
  • Optionally, a message body

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 /sams/testpage.html HTTP/1.0

In 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

/sams/testpage.html.

In this example the server resource we seek is on our own server, so we have quoted a relative path. It could of course be on another server elsewhere, in which case the server resource would include the full URL.

Header 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/html

By 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) .

HTTP request methods include POST, GET, PUT, DELETE, and HEAD. By far the most interesting for the purposes of this book are the GET and POST requests. The PUT, DELETE, and HEAD requests are not covered here.

You can leave a response, or trackback from your own site.

One Response to “The HTTP Request”

  1. Centre Society,strong fashion however road around afraid happy activity local result domestic relative with rest marry number club address potential discussion former address success relatively initiative record huge panel check department fill family reply attract boat bloody of daughter circumstance simply hide enjoy view debt east scale earth bloody include guide little account outside member commercial foreign strike handle motor theme assembly impression requirement fashion reduction realise cry exercise used occasion concentration private obviously solicitor produce weak first attitude type director building such practical clean absolutely read provided county inform

Leave a Reply

Powered by WordPress | Visit www.iFreeCellPhones.com for Free Cell Phones. | Thanks to Palm Pre Blog, Find Best CD Rates and Fat burning furnace