- by x32x01 ||
Every time you browse the internet, your browser and the server talk to each other using HTTP - the Hypertext Transfer Protocol. This “language” defines how requests and responses work between clients and servers.
If everything works fine, the server responds:
What Are HTTP Status Codes? ⚙️
HTTP status codes tell you what happened to your request. They’re divided into five main categories:- 1xx - Informational: The request is received and being processed.
- 2xx - Success: Everything went well! For example:
- 200 OK: Request succeeded.
- 201 Created: A new resource was created (e.g., after a POST).
- 3xx - Redirection: You’re being redirected somewhere else.
- 301 Moved Permanently or 302 Found are common.
- 4xx - Client Error: Something’s wrong with your request.
- 400 Bad Request or 404 Not Found (the most famous one 😅).
- 5xx - Server Error: The issue is on the server side.
- 500 Internal Server Error or 503 Service Unavailable.
Common HTTP Methods 🧩
Methods tell the server what kind of action you want to perform:- GET: Retrieve information from a server (e.g., load a web page).
- POST: Send data to the server (like submitting a form).
- PUT: Update or replace an existing resource.
- DELETE: Remove a resource from the server.
- HEAD: Like GET, but returns only headers (useful for testing).
- PATCH: Partially update a resource.
Example of an HTTP Request 📦
Code:
POST /login HTTP/1.1
Host: example.com
Content-Type: application/json
{
"username": "admin",
"password": "12345"
} If everything works fine, the server responds:
Code:
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Login successful!"
} Why These Matter for Developers 💡
Understanding status codes and methods helps you:- Debug web apps faster.
- Write cleaner APIs.
- Improve user experience (e.g., proper error handling).
Last edited: