Everything about HTTP
Details about HTTP, Port Number, Status Codes, Request Methods, and Headers
What is HTTP?
- HTTP is a hypertext transfer protocol.
- HTTP is basically built on
TCP
(Transmission Control Protocol). TCP is a lower-level protocol that handles other lower-level important stuff that HTTP does not have to worry about.
Status Codes
1XX
- Information2XX
- Success3XX
- Redirect4XX
- Client Error (like404 NOT FOUND
), Here the client is responsible for the error.5XX
- Server Error (like503 Server Not Available
), Here server is responsible for the error.
Port Number
- Like
http
we also havehttps
,ftp
,ssh
etc which have some port number assigned to it. - It is mainly done to distinguish between all these, as when we will search for something then how our computer will know whether to use
http
orhttps
.
Port Number assigned:-
http
- 80https
- 443ftp
- 21,ftp
stands for File Transfer Protocol.ssh
- 22,ssh
stands for Secure Server Protocol.
Note:-
- When we will search for
https://google.com
then by default, the search will be forhttps://google.com:443
- By all these ports it doesn’t mean that
https
will not work with the port number234
, it will work but it is not what anyone will advise someone to do.
More about Port Numbers
- Port numbers are not infinite. They are finite and they range from 0 to 65535. That simply means we cannot start any port number great than 65535.
- Port numbers below 1023 are privileged port numbers. They require certain administrative access to be opened.
Request Methods
GET
method is the default request method.- Mostly we do use
GET
methods to browse most of the web. GET
basically means that you are visiting web pages.POST
means you want to interact or send some data to the server.POST
is used to communicate data to the server.PUT
- Its functionality is the same as that ofPOST
but if we will usePUT
rather thanPOST
then our server and client both know that we want to create the resource.PATCH
means to edit the resource.DELETE
means to delete a particular resource.
NOTE :-
-
GET
is the method should not have a body as if it will store some data like username, and password then anyone can access those data via just visiting the site.- We can do anything we want using
GET
andPOST
on the internet underhttp
. These two are the most powerful methods to use.- Functionality wise
POST
is the most superior as it can perform as others as well. BecausePOST
contain theRequest Payload
body which contains the resources.
Request Headers
- HTTP headers are just a way to provide more information to the request.
- For example
Content-Type: text/html
, this content-type header simply tells which type of content we have.
Full View of the Request Header
:authority: codedamn.com
:method: GET
:path: /
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-GB,en-US;q=0.9,en;q=0.8,hi;q=0.7
cookie: _gcl_au=1.1.659405939.1664042912; _ga=GA1.1.1679921718.1664042913; _fbp=fb.1.1664042912877.1560911668; AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImR1a2U3ODYiLCJfaWQiOiI2MTFjYTUyYzQxYzRhMTAwMDhlNDg4M2QiLCJuYW1lIjoiTW9oaXQgTWlzaHJhIiwiaWF0IjoxNjY0MDQzODM1LCJleHAiOjE2NjkyMjc4MzV9.uzly7qoYubm5iW-vok9M4c7kKG-Qd3HZ6YPKVKQSy4k; amp_824c80=XqiaBPuVfqgshtUxKQWhWe...1ge1rdkrm.1ge1rdkrm.1.2.3; _clck=1drazbx|1|f59|0; crisp-client%2Fsession%2F3e9d1351-f1a3-4320-986d-a97e915064bd=session_b9678a0f-dd6f-4726-95d0-fbbd9d6f8f9f; _clsk=o2x2c1|1664372093460|10|1|n.clarity.ms/collect; _ga_5Q1YFB1R0F=GS1.1.1664372054.10.1.1664372095.0.0.0; amp_824c80_codedamn.com=XqiaBPuVfqgshtUxKQWhWe.NjExY2E1MmM0MWM0YTEwMDA4ZTQ4ODNk..1ge24s6mj.1ge24teib.26.e.2k
referer: https://www.google.com/
sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: cross-site
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Firstly, know that:
- URLs are a type of URI
- URNs are a type of URI
- URCs are a type of URI
and there are many other
URI
- A standard for identifying documents using a short string of numbers, letters, and symbols.
- Defined by
https://datatracker.ietf.org/doc/html/rfc3986
Examples:- URLs, URNs, URCs, and many others.
URL
- Contains information about how to fetch a resource from its location.
- Always start with the protocol
- Can be relative
Examples:
http://example.com/mypage.html
file:///home/user/file.txt
tel:1-888-555-5555
URN
- Identifies a resource by a unique and persistent name, but doesn’t necessarily tell you how to locate it on the internet.
- It usually starts with the prefix urn:
Examples:
urn:isbn:0451450523
to identify a book by its ISBN number.urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66
a globally unique identifier
URC
- Points to metadata about a document rather than to the document itself.
- An example of a URC is one that points to the HTML source code of a page
- Examples:- like:
view-source:http://example.com/