DEV Community

How HTTP works?

Inam Ul Haq on May 23, 2020

HTTP is a protocol used for WWW(World Wide Web) which serve us functional websites, web applications, and web APIs. HTTP clients (internet browsers...
Collapse
 
ltvan profile image
Van Ly

Literally HTTP can be used over UDP but actually, HTTP until v2 is not designed for UDP transport. And you will never see any browser support HTTP over UDP. HTTP/3 may change that but it's too soon to say.

Collapse
 
v6 profile image
🦄N B🛡

How did you get the CLI output you showed in your post? Did you use curl?

Collapse
 
inambe profile image
Inam Ul Haq • Edited

I used Firefox dev tools' Raw Headers option:

Collapse
 
inambe profile image
Inam Ul Haq

For response:

There are better options though.

Collapse
 
petoroland profile image
Roland Pető

You can also use curl -v.

Collapse
 
chasemourn profile image
eeee

Nice

Collapse
 
ashutosh123joshi profile image
ashutosh123joshi

What is the request generated or what is the process happened when we hit google.com on browser?

Collapse
 
inambe profile image
Inam Ul Haq

What is the request generated

If you meant where; browser generate HTTP request for us.

what is the process happened when we hit google.com on browser?

Browser uses TCP/IP protocol to connect to google.com's server(DNS routing happens here). When connection is made, browser send HTTP request(which is essentially a text) to server using the connection. Server then respond to browser using same connection and browser receives and interpret that.

I'll further explain TCP/IP and connections in my next post where I'll create a bare(not using high-end APIs like provided by node and frameworks like express) web server using TCP/IP.

Collapse
 
parascode007 profile image
Paras-code-007

What are these new versions of http like http2 and how these are different from http

Collapse
 
inambe profile image
Inam Ul Haq

HTTP, in its essence, is just rules agreed by concerned orgs and people. Now, rules change for betterment, so did HTTP rules over the time, and there are several HTTP versions(HTTP 1.0, HTTP 1.1, HTTP 2 ...). These rules need to be implemented by both clients(browsers) and servers(apache, nginx) to be fully functional (e.g. if server respond with HTTP 2 response but browser didn't implement HTTP 2 it won't work). HTTP 2 is a major release which defines new rules and it's completely different from HTTP 1.X but it has yet to be as popular/supported as HTTP1.X.

Collapse
 
psanny11 profile image
santhosh

Http2 means