Ajax Bestiary: A Javascript Field Guide
 
Ajax Bestiary: A Javascript Field Guide
 
 

Under The Hood With HTTP: Part 3 Methods

Posted by Don Albrecht

Requests and responses make HTTP work; they are the yin and yang of Client / Server communications.  Last time, I covered some of the most common response codes and what they mean.  Today, I will be covering the different ways in which these communications can be called from the client.GET and POSTGET and POST are the 2 most common request methods.  GET is intended for the retrieval of information while POST is intended for the submission of information as a subordinate of the requested resource.When To Use GETGET should only be used when security is not an issue and all information can be included as part of the URL string.  GET has added the benefit in that it can be used with Cacheable data to reduce network usage.  Most server side environments allow you to include and process information included in the URI of the GET request.  This is generally a bad idea as all information included in the URI is transmitted in a form potentially visible to third parties.  Where security is not an issue that can be a more efficient way of getting information to a server.When To Use POST POST is ideally suited to transmitting dynamic information to the server.  Post supports the following benefits over GET for this purpose.

  • Information is not included in public facing URI request.
  • Larger quantities of data can be transmitted
  • Request data is not cached

Other MethodsThere are several other methods supported by HTTP 1.1 that you may find useful at some point.  Not all of these are readily accessed from within the Browser environment, however.

  • HEAD: Identical to GET except only the header and no body is returned
  • PUT: Requests that the attached body be stored under the requested URI.  If the resource already exists, it should be overwritten by the new version.
  • DELETE: Requests that the resource at the requested URI be deleted.
  • TRACE: A Debugging method, it requests that the request (as received by the server) be transmitted back to the client in the entity body.
  • CONNECT: A reserved name for future support for dynamically switching to tunnel proxies.


Leave a Reply