DEV Community

Sreekar Reddy
Sreekar Reddy

Posted on • Originally published at sreekarreddy.com

πŸ“¬ HTTP Explained Like You're 5

The postal service of the web

Day 15 of 149

πŸ‘‰ Full deep-dive with code examples


Sending Mail

When you send a letter:

  1. Write your message
  2. Put in envelope with address
  3. Post office delivers it
  4. Recipient reads and replies
  5. Reply comes back to you

HTTP works the same way for websites!


How Web Pages Work

Your browser wants to see google.com:

Browser: "Dear Google, please send me your homepage"
                    ↓ (travels over internet)
Google: "Sure! Here's the HTML, CSS, and images"
                    ↓ (travels back)
Browser: "Got it!" (shows you the page)
Enter fullscreen mode Exit fullscreen mode

This each way trip is an HTTP Request/Response.


The Message Format

Request (what you ask for):

GET /search?q=cats
Host: google.com
Enter fullscreen mode Exit fullscreen mode
  • GET = I want to read something
  • /search?q=cats = the specific page
  • Host: google.com = who I'm asking

Response (what you get back):

200 OK
Content-Type: text/html

<html>Here's your page!</html>
Enter fullscreen mode Exit fullscreen mode
  • 200 OK = Success! βœ…
  • 404 Not Found = Page doesn't exist ❌

Common HTTP Methods

Method What it does
GET Read data
POST Send new data
PUT Update data
DELETE Remove data

In One Sentence

HTTP is the language browsers and servers use to send requests and receive responses over the web.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

Top comments (0)