Web Client and Server dialogue.

The HTTP request

  • Here is an example URL (Uniform Resource Locator ).
    http://www.anycompany.com:80/index.html 
    The browser interprets the URL as follows:
    • HTTP:// is the protocol.
    • Contact a computer over the network with the hostname of www.anycompany.com
    • :80 - connect to the computer at port 80.
    • Anything after the hostname and optional port number is regarded as a document path.
  • The Request data transfer contain a header, with the first line as a request command method and a body with optional supported data containing details related to the request command.
    Example of a HTTP request header
    1
    2
    3
    4
    5
    6
    7
    GET /index.html?name=Robert&age=20 HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
    Host: www.anycompany.com
    Connection: Keep-Alive
    
    1. The first line tells a GET method request of a document /index.html from the server. HTTP/1.1 is given as the version of the HTTP protocol that the browser uses. The "name=Robert&age=20" are details related to the request and a part of the URL for a GET request.
    2. The second line tells the server what kind of documents are accepted by the browser.
    3. The third line indicates that the preferred language is English.
    4. The fourth line indicates that the client understands how to interpret a server response that is compressed with the gzip or deflate algorithm.
    5. In the fifth line, beginning with the string User-Agent, the client identifies itself as Mozilla version 4.0, running on Windows NT. In parenthesis, it mentions that it is really Microsoft Internet Explorer version 5.01.
    6. The sixth line tells the server what the client thinks the server's hostname is. This header is mandatory in HTTP 1.1, but optional in HTTP 1.0.
    7. The seventh line (Connection :) tells the server to keep the TCP connection open until explicitly told to disconnect.
    Example of a HTTP request body
    name=Robert&age=20
    
    As for a GET request, related details will appear as a part of the URL, but for the POST these details will apear in the body part of the request.

The HTTP request methods

  • A client request method is a command or request that a web client issues to a server.
    Request Method Description
    GET This means that you just want to retrieve a resource on the server. This resource could be the contents of a static file or invoke a program that generates data.
    POST Says that you're providing some information of your own (generally used for fill-in forms). This typically changes the state of the server in some way. For example, it could create a record in a database.
    HEAD This means that you just want some information about the document, but do not need the document itself.
    PUT This must be used to store data from client into a named server resource.
    DELETE This must be used to delete a named resource from a server.
    TRACE With this you asks the proxies to declare themselves in the headers, so the client can learn the path that the document took (and thus determine where something might have been garbled or lost). This is used for protocol debugging purposes.
    OPTIONS This is used when the client wants to know what other methods can be used for that document (or for the server at large).
    CONNECT This is used when a client needs to talk to a HTTPS server through a proxy server.

  • The Request GET and POST are the most used methods.