Lesson 30 minNEW
HTTP Fundamentals
00:00 / 00:00
What is HTTP?
HTTP (HyperText Transfer Protocol) is the foundation of data communication on the World Wide Web. Every time you load a webpage, submit a form, or call an API, you are using HTTP.
HTTP is a stateless, request-response protocol. The server doesn't remember who you are between requests — that's what cookies and sessions are for.
HTTP Request Structure
Every HTTP request has three parts:
- Request Line — Method, URL, and HTTP version (e.g.,
GET /api/users HTTP/1.1) - Headers — Key-value metadata like
Content-Type,Authorization,Accept - Body — Optional data payload (only in POST, PUT, PATCH)
HTTP Methods
- GET — Retrieve data. Should never modify anything.
- POST — Create a new resource.
- PUT — Fully replace a resource.
- PATCH — Partially update a resource.
- DELETE — Remove a resource.
bash# GET request — fetch all users curl -X GET https://api.example.com/users # POST request — create a new user curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -d '{"name": "Shark", "email": "shark@javashark.in"}'
HTTP Status Codes
Status codes tell you what happened on the server:
- 2xx — Success →
200 OK,201 Created,204 No Content - 3xx — Redirection →
301 Moved Permanently,302 Found - 4xx — Client Error →
400 Bad Request,401 Unauthorized,404 Not Found - 5xx — Server Error →
500 Internal Server Error,503 Service Unavailable
Summary
HTTP is the backbone of the web. As a backend developer, you will design and consume HTTP APIs every single day. Mastering HTTP methods, status codes, headers, and request/response cycles is non-negotiable.