Our Blog:

Demystifying HTTP Methods and Status Codes: A Developer's Guide


All
Andrej Vajagic

Andrej Vajagic

14.12.2023, 17:21

Read time: undefined mins

Demystifying HTTP Methods and Status Codes: A Developer's Guide

HTTP Methods: The Web's Handshakes

HTTP, the backbone of data communication on the web, uses various methods to indicate the desired action on a given resource. These are akin to different types of handshakes in the digital world.

1. GET: The Observer

  • Usage: Requests data from a specified resource.
  • Analogy: Like window-shopping, it's all about looking, not touching.
  • Best Practice: Should only retrieve data, not change it.

2. POST: The Creator

  • Usage: Submits data to be processed to a specified resource.
  • Analogy: Filling out a form and submitting it.
  • Best Practice: Use for creating new resources or complex operations.

3. PUT: The Organizer

  • Usage: Replaces all current representations of the target resource with the request payload.
  • Analogy: Replacing an old notice with a new one on a bulletin board.
  • Best Practice: Ideal for updating existing resources.

4. DELETE: The Eraser

  • Usage: Removes specified resources.
  • Analogy: Like shredding a document – it’s gone for good.
  • Best Practice: Use with caution; ensure proper authentication.

5. PATCH: The Editor

  • Usage: Partially modifies a resource.
  • Analogy: Correcting a typo in a printed notice without changing the entire content.
  • Best Practice: Preferable for partial updates.

HTTP Status Codes: The Web's Responses

Status codes are the web's way of saying how it feels about the request you made. They're grouped into five classes:

Informational (100-199)

  • 100 Continue: A provisional response indicating that the initial part of the request has been received and the client should continue with the request.
  • 101 Switching Protocols: Informs the client that the server is switching to the protocols specified in the request.
  • 102 Processing (WebDAV): Indicates that the server has received and is processing the request, but no response is available yet.
  • 103 Early Hints: Used to return some response headers before final HTTP message.
  • 104 Reserved for future use: Placeholder for future HTTP extensions that may define additional informational status codes.

Successful (200-299)

  • 200 OK: The request has succeeded, and the response contains the requested data.
  • 201 Created: Indicates that a new resource has been successfully created in response to the request.
  • 202 Accepted: The request has been accepted for processing, but the processing is not complete.
  • 203 Non-Authoritative Information: The server is returning information that was provided by an entity other than the origin server.
  • 204 No Content: The server successfully processed the request, but is not returning any content.

Redirection (300-399)

  • 300 Multiple Choices: Indicates multiple options for the resource that the client may follow.
  • 301 Moved Permanently: The requested resource has been permanently moved to a new URI.
  • 302 Found: The requested resource is temporarily under a different URI.
  • 303 See Other: The response to the request can be found under a different URI and should be retrieved using a GET method.
  • 304 Not Modified: Indicates that the resource has not been modified since the last request.

Client Error (400-499)

  • 400 Bad Request: The server cannot or will not process the request due to an apparent client error.
  • 401 Unauthorized: Authentication is required and has failed or has not been provided.
  • 403 Forbidden: The server understood the request but refuses to authorize it.
  • 404 Not Found: The requested resource could not be found but may be available in the future.
  • 405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.

Server Error (500-599)

  • 500 Internal Server Error: A generic error message indicating an unexpected condition was encountered.
  • 501 Not Implemented: The server does not support the functionality required to fulfill the request.
  • 502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
  • 503 Service Unavailable: The server is currently unable to handle the request due to temporary overloading or maintenance.
  • 504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.

In Conclusion

Understanding HTTP methods and status codes is like learning the basic grammar of the web. As a tech architect, it’s essential to know these to design efficient, user-friendly websites and applications. Embrace these concepts, and you'll be speaking the web's language fluently!

Remember, the web is an ever-evolving platform. Stay curious, keep learning, and you'll be a tech guru in no time! πŸš€πŸŒπŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Share:

Accelerating Digital Success. Experience the future of web development – faster, smarter, better. Lets innovate together.

Β©2024 Dreit Technologies | All rights reserved

Contact

  • +38 64 577 3034
  • Serbia
  • Marka Pericina Kamenjara 11A, Ruma
  • Contact us