Responses

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

A server (usually a web application) sends responses to a client (web browser or another web application) after it receives a request. The web application usually receives the request, performs an operation - maybe stores, retrieves, updates or deletes some information in a database - then returns a response. Just like HTTP provides a way to categorize requests, it has a way of categorizing responses. There are many things we might want to communicate in a response from a web application - was the request fulfilled correctly? Was there an error? Did the server not know how to respond to the data provided? Was the resource not found on the server? HTTP gives us a way to communicate this information with HTTP response status codes.

There are many response codes available to use, but we’ll outline a few of the most common ones when creating a web application. These response codes are all numbered and are usually three digits. Similar response codes share the same hundreds digit (eg. 200s, 300s, 400s, 500s). You may recognize some of these codes from browsing the web!

  • 200s - Successful responses
    • 200 OK - the request succeeded. This is probably the most common response.
    • 201 Created - the request succeeded and a new resource has been created
  • 300s - Redirection Messages
    • 301 Moved Permanently - The URL for the resource has changed permanently. The new URL is given along with the response.
    • 302 Found - The URL for the resource has changed temporarily.
  • 400s - Client error responses
    • 404 - Not found - The requested resource could not be found. Usually you see this when you enter a URL that doesn’t exist.
    • 405 - Method not allowed - The HTTP request method is known by the server but has been disabled. We may see this in the hands on portion.
  • 500s - Server error responses
    • 500 - Internal Server Error - The server encountered a situation it doesn’t know how to handle - you see a lot of these in developing web applications when you make syntax errors, etc.