Important HTTP Methods
HTTP methods define what operation the client wants to perform on a resource.
Method | Purpose | Common Use |
|---|---|---|
GET | Retrieve data | Fetch a webpage, product, or API record |
POST | Submit or create data | Create user, submit form, send payload |
PUT | Replace an existing resource | Full update of a resource |
PATCH | Partially update a resource | Change selected fields only |
DELETE | Remove a resource | Delete an item or record |
HEAD | Retrieve headers only | Check metadata without full body |
OPTIONS | Ask what operations are allowed | API capability and CORS-related checks |
In web APIs, these methods are a major part of good design.
HTTP Status Codes
HTTP status codes are three-digit numbers returned by the server to describe the outcome of a request.
The five main classes are:
1xx Informational: Request received, processing continues
2xx Success: Request completed successfully
3xx Redirection: More action is needed
4xx Client error: Something is wrong with the request
5xx Server error: The server failed while handling a valid-looking request
Some common codes are:
Status Code | Meaning | Typical Use |
|---|---|---|
200 OK | Success | Standard successful response |
201 Created | New resource created | Successful |
204 No Content | Success with no body | Delete or update with no payload return |
301 Moved Permanently | Permanent redirect | Resource moved to new URL |
302 Found | Temporary redirect | Temporary location change |
304 Not Modified | Cached version can be used | Cache validation |
400 Bad Request | Invalid request | Malformed input or missing fields |
401 Unauthorized | Authentication required | Missing or invalid credentials |
403 Forbidden | Access denied | Authenticated but not allowed |
404 Not Found | Resource does not exist | Wrong path or missing record |
409 Conflict | Request conflicts with current state | Duplicate or conflicting update |
500 Internal Server Error | Generic server failure | Unexpected backend issue |
503 Service Unavailable | Temporary server overload or downtime | Maintenance or heavy load |
Status codes are essential because clients often make decisions based on them.
HTTP Methods
Important HTTP Headers
Headers carry metadata that helps both client and server understand how to process the message.
Common request and response headers include:
Host: Identifies the target host in HTTP/1.1 requests
Content-Type: Describes the data format, such as
application/jsonAccept: Tells the server which response format the client prefers
Authorization: Carries authentication credentials or tokens
Cache-Control: Controls caching behavior
User-Agent: Identifies the client software
Cookie: Sends session-related data
Set-Cookie: Lets the server create or update cookies
Location: Often used in redirects or after resource creation
Headers are a major part of HTTP because they make the protocol flexible without changing the core request-response structure.
Be the first to add a comment.