#HTTP & HTTPS
The foundation of web communication.
#HTTP Methods
| Method | Purpose | Idempotent |
|---|---|---|
| GET | Retrieve data | Yes |
| POST | Create resource | No |
| PUT | Update/replace | Yes |
| PATCH | Partial update | No |
| DELETE | Remove resource | Yes |
| HEAD | Headers only | Yes |
| OPTIONS | Get methods | Yes |
#Status Codes
| Range | Category | Examples |
|---|---|---|
| 1xx | Informational | 100 Continue |
| 2xx | Success | 200 OK, 201 Created |
| 3xx | Redirect | 301 Moved, 302 Found |
| 4xx | Client Error | 400 Bad Request, 404 Not Found |
| 5xx | Server Error | 500 Internal, 503 Unavailable |
#HTTPS
HTTPS = HTTP + TLS encryption
Loading diagram...
#Testing with cURL
bash
1# GET request
2curl https://api.example.com/users
3
4# POST with JSON
5curl -X POST -H "Content-Type: application/json" \
6 -d '{"name":"John"}' https://api.example.com/users
7
8# With headers
9curl -H "Authorization: Bearer token" https://api.example.com
10
11# Show response headers
12curl -I https://example.com
13
14# Verbose mode
15curl -v https://example.com