HTTP Methods

Thu, 11/10/2016 - 13:11 -- pottol

HTTP Methods represent the desired action to be performed on the identified resource.

Like Status Codes, Header Fields and URIs, available Methods are the same in HTTP/1.1 and HTTP/2.

The list of available HTTP Methods is below, splitted in:

  1. Mandatory: absolutely needed. These are about Reading (the main purposes of HTTP are concerned about reading and watching at resources)
  2. Recommended: most used in production environment. These are about Writing (important purposes of HTTP are concerned about allowing users to add/fill some information)
  3. Discouraged: staging or specialpurposes. These are about eXecuting (uncommon purposes of HTTP are concerned about testing and issuing connections)

Another classification of methods is about the objects these are operating upon:

  • Part: operating on a proper portion of the object (usually meta-information)
  • All: operating on the entire object
  • Side: operating specific functions 

Thus, the methods could be arranged by the follow 3x3 table:

 

  PART ALL SIDE

MANDATORY

(READ)

HEAD GET OPTIONS

RECOMMENDED

(WRITE)

POST PUT DELETE

DISCOURAGED

(EXECUTE)

TRACE CONNECT PATCH

Mandatory HTTP Methods

Methods that are needed for accessing (reading) resources:

  • HEAD: asking for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content
  • GET: requesting a representation of the specified resource. Requests using GET (and a few other HTTP methods) "SHOULD NOT have the significance of taking an action other than retrieval"
  • OPTIONS: returning the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource

Recommended (production environment) HTTP Methods

Methods that are needed for interacting (writing) to the server:

  • POST: submitting data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both
  • PUT: uploading a a representation of the specified resource
  • DELETE: deleting the specified resource

Discouraged (staging or special environment) HTTP Methods

Methods that are useful for treating specially the connection:

  • CONNECT: converting the request connection to a transparent TCP/IP tunnel, usually to facilitate SSL-encrypted communication (HTTPS) through an unencrypted HTTP proxy
  • PATCH: used to apply partial modifications to a resource
  • TRACE: echoeing back the received request, so that a client can see what (if any) changes or additions have been made by intermediate servers