Sobes.tech
Middle

Tell me about HTTP requests: what do you know about them, what are they used for, what are the main response codes?

sobes.tech AI

Answer from AI

HTTP requests are a way for a client to interact with a server using the HTTP protocol. The client sends a request with a method (GET, POST, PUT, DELETE, etc.), headers, and, if necessary, a body.

Main tasks of HTTP requests:

  • Data retrieval (GET)
  • Sending data to the server (POST)
  • Updating data (PUT/PATCH)
  • Deleting data (DELETE)

Main HTTP response codes:

  • 2xx — successful responses (e.g., 200 OK, 201 Created)
  • 3xx — redirections (e.g., 301 Moved Permanently)
  • 4xx — client errors (e.g., 400 Bad Request, 401 Unauthorized, 404 Not Found)
  • 5xx — server errors (e.g., 500 Internal Server Error)

Example: when making a GET /users request, the server may return 200 OK with a JSON list of users, and in case of an authorization error — 401 Unauthorized.