HTTP is a stateless protocol. It is the communication protocol that transfers representations of resources over a network for e.g., web [ACL+05]. According to the architectural constraints referred by Fielding [Fie00] , Statelessness was one of the six points mentioned. What stateless means is to restricting the server to maintain the state of the interaction between the client and server and rather ensure that the relevant information must be transferred within the request from each client to the server. This constraint improves the properties of visibility, reliability, and scalability. This means that proxies and other intermediaries would be able to participate in communication patterns that involve self-descriptive stateless messages, server death and failover will not result in session state synchronisation problems, and it is easy to add new servers to handle client load again without needing to synchronise session state.
Reliability is improved because it eases the task of recovering from partial failures [Fie00]
[WWWK94]. Scalability is improved because services do not need to persist state and do not consume memory, representing active interactions hence allows the server component to quickly free resources and further simplifies implementation.
HTTP aka Hyper Text Transfer protocol is an underlying network protocol used by World Wide Web (WWW). It very well defines how the message formatting and transmitting has to happen along with explaining what actions Web servers and browsers should take in response to various commands. For example, entering a URL in the browser, actually sends a HTTP command to the web server directing it to fetch and transmit the requested web page.
REST is considered a simple way to organize interaction between dissimilar and independent systems. It is not at all confined to the web but when it has to be implemented for the design of a web-based services, it can use HTTP as a protocol for the interactions [Fie00]. REST and HTTP go hand in hand and therefore as mentioned at 2.4, the CRUD - four generic verbs are used along with REST. HTTP is hence a stateless protocol which means that it executes each command independently irrespective of knowing what the previous command or the previous request including the content and metadata like headers etc. was.
2.5.1 Status Codes
HTTP status codes are "standard response codes" given by the servers/clients when an error occurs over the network in communication. These codes help identify the cause of the problem when a web page or other resource do not load properly. The term HTTP status code is actually the common term for the HTTP status line that includes both the HTTP status code and the HTTP reason phrase-reason or relevant message for the same. The Reason-Phrase is intended to give a short textual description of the Status-Code and is intended for the easy readability of the user. HTTP Codes indicate whether a specific HTTP request has been successfully completed. These responses are grouped in five classes: informational responses, successful responses, redirection, client errors, and servers errors. Some of the basic codes are listed below:
2.5 Hyper Text Transfer Protocol (HTTP)
The server has received the request headers, and the client should proceed to send the request body
103 Checkpoint Used in the resumable requests proposal to re-sume aborted PUT or POST requests
2xx:Successful
200 OK The request is OK (this is the standard response
for successful HTTP requests)
201 Created The request has been fulfilled, and a new re-source is created
204 No Content There is no content to send for this request, but the headers may be useful.
3xx:Redirection
303 See Other The requested page can be found under a differ-ent URL
4xx:Client Error
400 Bad Request The request cannot be fulfilled due to bad syntax 401 Unauthorized The request was a legal request, but the server
is refusing to respond to it.
404 Not Found The requested page could not be found but may be available again in the future
5xx:Server Error
500 Internal Server
Er-ror
A generic error message, given when no more specific message is suitable
501 Not Implemented
The server either does not recognize the request method, or it lacks the ability to fulfil the re-quest.
2.5.2 Methods
RESTful web services expose resources (both data and functionality) through web URIs and they use the four main HTTP methods called CRUD actions namely GET , POST , UPDATE and DELETE to create, retrieve, update, and delete respectively in order to manage and modify the resources. The HTTP verbs comprise a major portion of the "uniform interface"
constraint. The primary or most-commonly-used HTTP verbs (or methods) are POST, GET, PUT and DELETE. These correspond to create, retrieve , update, and delete (or CRUD) operations, respectively. Furthermore description of these are:
Table 2.2:HTTP Methods with corresponding CRUD Action
The HTTP GET method is used to retrieve (or read) a representation of a resource. In the non-error path, GET returns a representation in XML or JavaScript Object Notation (JSON) and an HTTP response code of 200 (OK) (table 2.1). In an error case, it returns a 404 (NOT FOUND) or 400 (BAD REQUEST) (table 2.1) for client side-errors whereas 500 (INTERNAL SERVER ERROR) for the server-side error. According to the design of the HTTP specification, GET (along with HEAD) requests are used only to read data and not change it. Therefore, when used this way, they are considered safe. That is, they can be called without risk of data modification or corruption—calling it once has the same effect as calling it several times, or none at all which means GET (and HEAD) is idempotent, which means that making multiple identical requests ends up having the same result as a single request. It is recommended not to expose unsafe operations via GET—it should never modify any resources on the server [RR07].
POST
The POST verb is most-often utilized for creation of new resources. In particular, it is used to create subordinate resources that is, subordinate to some other (e.g. parent) resource, for e.g., a tenant contains tenant users or a shop contains products etc. Basically, when creating a new resource, POST to the parent and the service takes care of associating the new resource with the parent, assigning an ID (new resource URI) etc. On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the 201 HTTP status (table 2.1). POST is neither safe nor idempotent. It is therefore recommended for non-idempotent resource requests. Making two identical POST requests will most-likely result in two different resources containing the same information.
DELETE
It is used to delete a resource identified by a URI. On successful deletion, return HTTP status 200 (OK) (2.1) along with a response body, accompanying the representation of the deleted item or a wrapped response. It may either return HTTP status 204 (NO CONTENT) with no response body or a HTTP status 200, these are the recommended responses (table 2.1).
DELETE operations are idempotent as per HTTP specifications. A DELETE Method actually removes the resource completely. Therefore repeatedly calling DELETE on that resource ends