HTTP Response Codes

3-digit server status acknowledgment


25 Feb 2017 View Comments
#http #responsecode #status #acknowledgment #web #computer

When a client makes the request via HTTP, HTTP Response Code is the 3-digit status return code from the server. The first digit out of three represents the type/class of the response. The rest 2 digits are the identity numbers of the class. 5 classes of the HTTP Response codes are described in below table:

Response Class Code Response Class Code Group Description
1 Informational Received Request, processing
2 Success Received Request, successfully
3 Redirection Received Request, extra action
4 Client Error Received Request, client request error
5 Server Error Received Request, server error

Let me emphasize on some of the important class codes. Note below are not the “full” list. Please check wikipedia for the full list.

1xx Informational

It is purely used for information transfers. You could think of this act as the “ping”. It means the server received your request and currently working on it. 1xx has not be tuned further after HTTP/1.0. It is very rarely used as this isn’t a very useful class code.

  • 101 Switching Protocols: Sometimes used in WebSocket communication

2xx Success

This class of status codes indicates the request from the client was successfully received, understood, and accepted.

  • 200 OK: This response represents a general success. Most common HTTP Response code.
    • GET an entity corresponding to the requested resource is sent in the response;
    • HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;
    • POST an entity describing or containing the result of the action;
    • TRACE an entity containing the request message as received by the end server.
  • 201 Created: This is another success response code to indicate the resource had been successfully created.
  • 202 Accepted: Received the request but have not finished processing.
  • 204 No Content: Successfully processed yet no content is provided.
  • 206 Partial Content: Response has partial content. Usually, this means the client requested to set a boundary which server do as commanded.

3xx Redirection

This response code means to be able to complete the task for this response code, redirection must happen. This is common in URL Shortener service. They use either 301 or 302. They would write destination URL in location header.

  • 301 Moved Permanently: Use when content is permanently moved. This and all future requests should be directed to the given URL.
  • 302 Found: This action would still redirect but temporarily. Things can change in the future. Although many people use this response code as a standard for such action, this status code is probably improper usage of 303.
  • 303 See Other: When the client requests using GET method for another location, the server can respond with this code. It redirects everything except requested using HEAD.
  • 304 Not Modified: Another common response code beside 200. It is an indication of the last content has not been modified. The requester would make a request with the header, If-Modified-Since HTTP header with the date. The server is responsible for providing a correct response code. See RFC 7232 for details.
  • 307 Temporary Redirect: In this case, the request should be repeated with another URI; however, future requests should still use the original URI. In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. For example, a POST request should be repeated using another POST request.
  • 308 Permanent Redirect: The request and all future requests should be repeated using another URI. 307 and 308 parallel the behaviors of 302 and 301 but do not allow the HTTP method to change. So, for example, submitting a form to a permanently redirected resource may continue smoothly. Note: 307 and 308 are still in the early stage of being a standard which makes the modern browsers to understand correctly.

4xx Client Error

The 4xx class of status code is intended for cases in which the client seems to have errors. Except when responding to a HEAD request, technically the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method.

  • 400 Bad Request: There is something wrong with the client request. Browsers treat this the same as 200 OK.
  • 401 Unauthorized: Restricted Access. The server requires HTTP Authentication information.
  • 403 Forbidden: Restricted access. Server denied displaying the content either through permissions or restricted IPs.
  • 404 Not Found: There is no resource in the requested item.
  • 405 Method Not Allowed: Client is using unauthorized HTTP Method.

5xx Server Error

The 5xx class of status code intended for cases in which the server is aware that it has errors or is incapable of performing the request. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents should display any included entity to the user. These response codes are applicable to any request method.

  • 500 Internal Server Error: Server replied back to the client saying something is wrong processing request.
  • 503 Service Unavailable: Server cannot process requests temporarily. This usually happens when there are too many concurrent users to serve.
  • 504 Gateway Timeout: There was a problem path to the Gateway, timed out.
  • 505 HTTP Version Not Supported: Client is using the HTTP version that is unsupported
Share this post

Me

I am a passionate programmer working in Vancouver. I strongly believe in art of algorithms and together with it to write clean and efficient software to build awesome products. If you would like to connect with me, choose one from below options :) You can also send me an email at