Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a normal HTTP request and a REST request

Tags:

rest

http

I'm facing some issues in understanding the difference between a normal HTTP request and REST request. I've checked a few request and responses and they look the same to me. If they are indeed similar, how does the web service differentiate between a normal HTTP request and a REST request.

And yes, I know REST is an architecture style that defines how to use HTTP.

like image 911
Govind Madhu Avatar asked Mar 11 '23 18:03

Govind Madhu


1 Answers

REST stands for Representational State Transfer. This architecture is protocol independent but it is frequently implemented over the HTTP protocol.

The REST architectural style was defined in the chapter 5 of Roy Thomas Fielding's PhD dissertation (it's a must read if you are interested in REST). And the following set of constraints was added to this architectural style:

  • Client-server
  • Stateless
  • Cache
  • Uniform interface
  • Layered system
  • Code-on-demand

A REST request (that can be a HTTP request when the REST architecture is implemented over the HTTP protocol) must contain all information to be understood by the server, without taking advantage of any stored context on the server.

For instance, if you are performing a request to a protected resource, that is, a resource that requires authentication, the request must contain the credentials to be properly authenticated. In REST there's no session state on server side.

That's how the REST stateless constraint is defined:

5.1.3 Stateless

[...] each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client. [...]

like image 62
cassiomolin Avatar answered Mar 17 '23 17:03

cassiomolin