jump to navigation

HTTP Methods August 19, 2005

Posted by Coolguy in Networks.
Tags:
trackback

HTTP Methods

  • HTTP 1.1 Methods are GET,POST,OPTIONS,HEAD,TRACE,PUT,DELETE,OPTIONS,CONNECT
  • Methods can be safe or idempotent
  • Idempotent means doing the same thing again and again without no unwanted side effects
  • GET.HEAD,PUT,DELETE,OPTIONS,TRACE are idempotent
  • POST in not idempotent
  • OPTIONS: This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. Asks for list of http methods to which the requested URL can respond.
  • GET: The GET method means retrieve whatever information is identified by the Request-URI
  • A simple hyperlink is always GET
  • If there is no ‘method’ in a form, the default is GET
  • HEAD: The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.
  • POST: The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line.
  • PUT: The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server
  • DELETE: The DELETE method requests that the origin server delete the resource identified by the Request-URI
  • TRACE: The TRACE method is used to invoke a remote, application-layer loop- back of the request message.TRACE allows the client to see what is being received at the other end of the request chain and use that data for testing or diagnostic information. Asks for loopback of request message so that the client can see what’s being recieved on the other end.
  • CONNECT: Says to connect for the purposes of tunneling.

GET vs POST

  • Use GET if: The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup).
  • Use POST if: The interaction is more like an order, or The interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or The user be held accountable for the results of the interaction
  • Issues with GET are:
  • Size of data
  • Security
  • GET can be bookmarked
  • Developers who want to support both methods usually putlogic in doGet(), and then have the doPost() implementation delegate to that doGet()

More:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

http://www.w3.org/2001/tag/doc/whenToUseGet.html#principles-summary

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: