You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
HTTP (HyperText Transfer Protocol) is the protocol that powers the World Wide Web. It defines how clients (browsers) request resources and how servers respond. Understanding HTTP is essential for anyone working with web applications, APIs, or cloud services.
HTTP is a request-response protocol built on top of TCP:
Client (Browser) Server
│ │
│── HTTP Request ────────>│
│ GET /index.html │
│ │
│<── HTTP Response ───────│
│ 200 OK │
│ <html>...</html> │
| Method | Purpose | Safe | Idempotent |
|---|---|---|---|
| GET | Retrieve a resource | Yes | Yes |
| POST | Submit data to create a resource | No | No |
| PUT | Replace a resource entirely | No | Yes |
| PATCH | Partially update a resource | No | No |
| DELETE | Delete a resource | No | Yes |
| HEAD | Like GET but returns only headers | Yes | Yes |
| OPTIONS | Describes the communication options | Yes | Yes |
Safe means the method does not modify server state. Idempotent means calling it multiple times produces the same result.
GET /api/users HTTP/1.1
Host: example.com
Accept: application/json
Authorization: Bearer eyJhbGci...
User-Agent: Mozilla/5.0
| Component | Description |
|---|---|
| Method | The action to perform (GET, POST, etc.) |
| Path | The resource being requested (/api/users) |
| Version | HTTP version (HTTP/1.1, HTTP/2) |
| Headers | Metadata about the request |
| Body | Data sent with the request (POST, PUT, PATCH) |
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 85
Cache-Control: max-age=3600
{"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}
| Component | Description |
|---|---|
| Status code | A three-digit code indicating the result |
| Headers | Metadata about the response |
| Body | The requested resource or data |
| Range | Category | Examples |
|---|---|---|
| 1xx | Informational | 100 Continue, 101 Switching Protocols |
| 2xx | Success | 200 OK, 201 Created, 204 No Content |
| 3xx | Redirection | 301 Moved Permanently, 302 Found, 304 Not Modified |
| 4xx | Client error | 400 Bad Request, 401 Unauthorised, 403 Forbidden, 404 Not Found, 429 Too Many Requests |
| 5xx | Server error | 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable |
| Code | Meaning | When Used |
|---|---|---|
| 200 | OK | Successful request |
| 201 | Created | Resource successfully created (POST) |
| 301 | Moved Permanently | Resource has a new permanent URL |
| 304 | Not Modified | Cached version is still valid |
| 400 | Bad Request | Malformed or invalid request |
| 401 | Unauthorised | Authentication required |
| 403 | Forbidden | Authenticated but not authorised |
| 404 | Not Found | Resource does not exist |
| 500 | Internal Server Error | Unexpected server failure |
HTTPS (HTTP Secure) encrypts HTTP traffic using TLS (Transport Layer Security):
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.