HTTP
Who else not heard of http in the industry or outside it, as it the language that make the clients ( Like Browsers, Aplications, Robots, Crawlers, etc ) and servers communicate with each other. and there is HTTPS Which is an Encrypted and secure version of HTTP So no man in the middle can steal your data When your client communicats with the server. It is like sending messages to each others and thats the concept that http is build upon
HTTP-Messages
HTTP Messages Have Two Types :
- Request Messages : These are the messages that your client send to your
- Response Messages : These are the messages that the server respond to your client which return the requested resource which the client request
HTTP-Message-Components
HTTP Messages ( Request or Response ) Consists Of Three Parts
- Start Line
- Headers
- Message Body
1. Start Line
It is the start line of the message which determine if this message is request message or response message.
Request Start Line
The start line for request message is like this
[HTTP Method] [Resource Path] [HTTP/major.minor]
-
HTTP Method is the method that the client use to his Request.
The Common Methods Used is- GET
- POST
- DELETE
- PUT
- PATCH
- CONNECT
- HEAD
- OPTIONS
- TRACE
Resource Path is the resource path or the data path which the client wants from the server.
-
HTTP/major.minor is the HTTP Version which is consist of major version and minor version because there is http versions out there.
- HTTP/0.9 which is the older version
- HTTP/1.0
- HTTP/1.1 which is The Commonly used version
- HTTP/2.0 I think it is the last version
And Be Careful because there is space between the method and resource path and http version.
An Example For HTTP Request Message
GET /http/What-is-HTTP HTTP/1.1
Host : dev.to
Response Start Line
The Start Line for the response message is like this
[HTTP/major.minor] [Response Code] [Response Description Line]
- HTTP/major.minor is The HTTP version
-
Response Code is the response code that the server respond to client with it like
- 404 Which mean this resource not found
- 200 Which mean the resource found and there it is
- ...etc
Response Description Line this is just description text for the humans to understand. also note that the code for machine and the text for humans
An Example On HTTP Response Message
HTTP/1.1 200 Success
Server : Apache
Content-Type : text/html
Content-Length : 12
Hello World!
2. Headers
Headers is the data that describe the message and also an instructions to the message receiver ( client or server ) and contain other useful info about the message.
An Example on it
Server : Apache
X-Frame-Options : SAMEORIGN
Content-Length : 15
There is Many Headers But They Have Four Types
- General Headers Which Used in Request and Response Messages
- Entity Headers Which Contains information About The Message
- Request Headers Which is Headers That Reside in Request Messages
- Response Headers Which is Headers That Reside in Response Messages
3. Message Body
It Is The Resource Or Data The Client Wants Or The Server Receive
For More Resources I Think MDN Is Greet Place
Top comments (0)