                            Transactions and Methods

  A transaction defined

   As mentioned previously, a transaction is an HTTP request sent by the
   client, followed by a response from the server. As we are using Java to
   perform the actual transactions, we do not need to know the exact format
   of these requests, but it is useful to know what information is available
   to us. As already stated, this is a brief highlight of HTTP, no an
   in-depth reference. See RFC 2616 for more details [P1].

   An HTTP transaction consists of the following items:

     * A request sent from the client, consisting of:
         1. A request method
         2. Request headers (0 or more)
         3. Message body (if appropriate to request method)
     * A response from the server, consisting of:
         1. Response code and description of response code
         2. Response headers (0 or more)
         3. Response body (if appropriate to the message body)

   These are all summarised below:

  Methods

   There are several methods available to use in HTTP, but the next five
   cover the most used applications of HTTP.

    GET

   The GET method is the most commonly used method when browsing. This method
   returns an HTTP header, along with the document requested.

    HEAD

   The HEAD method acts like the GET method, but returns the HTTP header
   alone, with no message body. Useful for checking the size or last
   modification time of a document.

    POST

   Sends a small amount of information to the server, usually to be processed
   by a CGI script. The data is enclosed as a message body and requires a
   header field indicating the amount of data transmitted.

    OPTIONS

   This requires no special headers or method body and returns an extra
   header field, "Allow", which contains the methods accepted by the server.
   eg. GET, HEAD, POST, OPTIONS, TRACE etc.

    TRACE

   Used to simply verify connection is OK. Is a very simple equivalent to the
   'ping' command.

  Request & response header fields

   There are lots of header fields defined. The ones I find particularly of
   use are:

    Content-Length

   The length of the document body in bytes. Required when sending anything
   to a server using the POST method. This is available from both the GET and
   HEAD methods.

    Content-Type

   The MIME type of the document being transmitted. Beware, however, this
   requires the server to be setup correctly. An example is Microsoft's
   Internet Information Server, which uses Active Server Pages. These
   sometimes report as being "Content-Type: application/x-octet-stream", but
   in fact are returning standard HTML.

    Last-Modified

   The date the document was last modified. This can be very useful when
   comparing two documents for equality.

    Range

   Partially retrives a document. As an example, to get the first 1000 bytes
   of a document, and all bytes from position 9500, set this header field to
   "bytes=0-999,9500-" (no quotes).

    User-Agent

   Not neccessarily required, but if you're writing a web crawler which will
   visit many sites, it is polite to set this field to something meaningful,
   such as "University of Good Programming Web Crawler".

  Response codes

   HTTP uses response codes to summarise the success or otherwise of the
   transaction. It is a 3-digit integer representing the status of the
   request, grouped into 5 broad categories.

     * 1XX: Informational only - the server has received the request and is
       continuing to process it.
     * 2XX: Successful - The request has been fulfilled.
     * 3XX: Redirection - further action is required by the user or the
       software accessing the server
     * 4XX: Client error - the request was incorrect in some way (this
       includes trying to access a URL which does not exist).
     * 5XX: Server error - the server knows it has erred, but cannot rectify
       the problem.

   The most common response code is 200 (OK). Other response codes you may
   have seen are 403 (forbidden) and 404 (object not found). I have compiled
   a full list of error codes which have been defined by the HTTP 1.1
   standard.

          -----------------------------------------------------------

   Ian Burnett - 6th September  Previous page Next page Valid CSS! Valid HTML 
   1999                                                 4.0!                  
