HTTP REST - the essentials

2008-02-27 @ 21:18#

here are the essential 'tools' needed to write web apps that are REST-compliant:

  1. HTTPMethod tool

    this tool should be able to respond to incoming requests using common HTTP Methods (GET, HEAD, PUT, POST, DELETE, OPTIONS). it should be easy to accept a request, determine the HTTP Method, parse the request and assemble and ship the response to the client.

  2. HTTPClient tool

    this tool should allow programmers to make HTTP calls (GET, HEAD, PUT, POST, DELETE) without any fuss. for example:
    string results = httpClient.Execute(url,method='get',contentType='text/html',body=null)
    additional properties to handle headers, cookies, and credentials should also be available. with this in hand, you can start GETing, and POSTing web data, etc.

  3. WebCache tool

    this tool should allow programmers to manage internal caching to web request. usually it will include a Cache object that contains the item in the cache and a utility class that can read/write to the cache, remove items as needed, and provide support for responding to requests with HTTP 304 (Not Modified) when appropriate. a webcache tool can reduce processing (and pull from the cache instead) and reduce bandwidth (by returning 304s). it should be easy to cache and item, check the item on the cache, and determine that the item in the cache is the same one the client already holds (resulting in a 304).

  4. Compression tool

    this tool should provide support for GZip and/or deflate. it should be able to tell when clients support these encodings and only use them when supported.

  5. MimeType tool

    this tool should be able to determine the proper mime-type requested by the client and return that value for the app to work with.

  6. HTTPAuth tool(s)

    supporting HTTP Authentication (Basic and Digest) should be easy. it should be easy to handle requests for authentication from a remote machine. it should also be able to validate incoming authentication credentials and act accordingly.

  7. other tools

    support for things like MD5 hashing, Base-64 encoding, URI parsing, handling cookies, headers, etc. should also be readily available.

you have these in place and at the ready (along with lots of 'glue' to interface with local data stores) and you will have a powerful kit for building REST-compliant web apps.

code