HTTP protocol what is HTTP? HTTP stands for HyperText Transfer Protocol. The HTTP protocol can be used to transfer the data in the form of plain text, hypertext, audio, video, etc on the internet. features of HTTP HTTP is connectionless The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client waits for the response. Server processes the request and returns the response. Once response is recieved then HTTP client disconnects the connection. HTTP is media independent The client has to specify the media type in the request Then server will understand the media request and processes it. HTTP is stateless The server and client are aware of each other only during a current request. Afterwards, both of them forget about each other.
HTTP Request It has two parts HTTP request headers
and HTTP request body
The request looks something like below http://127.0.0.1:8000/login/
POST /login/ HTTP/1.1
Host: 127 .0.0.1
User-Agent: Mozilla/5.0 ( Windows NT 6 .1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml; q = 0 .9,*/*; q = 0 .8
Accept-Language: en-US,en; q = 0 .5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://127.0.0.1:8000/login/
Cookie: passx = 87e8af376bc9d9bfec2c7c0193e6af70; PHPSESSID = l9hk7mfh0ppqecg8gialak6gt5
Connection: keep-alive
Content-Type: multipart/form-data
HTTP request body HTTP Message Body is the data bytes transmitted in an HTTP transaction message immediately following the headers if there are any. HTTP response: It also has two parts HTTP response headers
and HTTP response body
200 OK
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Mon, 18 Jul 2016 16:06:00 GMT
Etag: "c561c68d0ba92bbeb8b0f612a9199f722e3a621a"
Keep-Alive: timeout=5, max=997
Last-Modified: Mon, 18 Jul 2016 02:36:04 GMT
HTTP response body The last part of a response is the body. Not all responses have one: responses with a status code that sufficiently answers the request without the need for corresponding payload (like 201 Created or 204 No Content) usually don't. HTTP status codes Informational responses (100 – 199) Successful responses (200 – 299) Redirection messages (300 – 399) Client error responses (400 – 499) Server error responses (500 – 599) References: