HTTP Status Codes for Rails Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser. HTTP status codes and their respective Rails symbol representations. For example,:notfound can be used instead of 404 in a render call: render file: '404.html.erb', status::notfound. Examples of using HTTP Status Codes in REST 201 – When doing a POST to create a new resource it is best to return 201 and not 200. 204 – When deleting a resources it is best to return 204, which indicates it succeeded but there is no body to return.
HTTP status codes and their respective Rails symbol representations. For example, :not_found
can be used instead of 404
in a render call:
1xx Informational
| The server has received the request headers, and that the client should proceed to send the request body. |
| The requester has asked the server to switch protocols and the server is acknowledging that it will do so. |
| The server has received and is processing the request, but no response is available yet. |
2xx Success
| The standard response for successful HTTP requests. |
| The request has been fulfilled and a new resource has been created. |
| The request has been accepted but has not been processed yet. This code does not guarantee that the request will process successfully. |
| HTTP 1.1. The server successfully processed the request but is returning information from another source. |
| The server accepted the request but is not returning any content. This is often used as a response to a |
| Similar to a |
| The server is delivering only a portion of the content, as requested by the client via a range header. |
| The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made. WebDAV - RFC 4918 |
| The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again. WebDAV - RFC 5842 |
| The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. |
Http Status Codes Cheat Sheet
3xx Redirection
| There are multiple options that the client may follow. |
| The resource has been moved and all further requests should reference its new URI. |
| The HTTP 1.0 specification described this status as 'Moved Temporarily', but popular browsers respond to this status similar to behavior intended for |
| The resource can be retrieved by following other URI using the |
| The resource has not been modified since the version specified in |
| HTTP 1.1. The resource is only available through a proxy and the address is provided in the response. |
| Deprecated in HTTP 1.1. Used to mean that subsequent requests should be sent using the specified proxy. |
| HTTP 1.1. The request should be repeated with the URI provided in the response, but future requests should still call the original URI. |
| Experimental. The request and all future requests should be repeated with the URI provided in the response. The HTTP method is not allowed to be changed in the subsequent request. |
4xx Client Error
| The request could not be fulfilled due to the incorrect syntax of the request. |
| The requestor is not authorized to access the resource. This is similar to |
| Reserved for future use. Shimano port devices driver. Some web services use this as an indication that the client has sent an excessive number of requests. |
| The request was formatted correctly but the server is refusing to supply the requested resource. Unlike |
| The resource could not be found. This is often used as a catch-all for all invalid URIs requested of the server. |
| The resource was requested using a method that is not allowed. For example, requesting a resource via a |
| The resource is valid, but cannot be provided in a format specified in the |
| Authentication is required with the proxy before requests can be fulfilled. |
| The server timed out waiting for a request from the client. The client is allowed to repeat the request. |
| The request cannot be completed due to a conflict in the request parameters. |
| The resource is no longer available at the requested URI and no redirection will be given. |
| The request did not specify the length of its content as required by the resource. |
| The server does not meet one of the preconditions specified by the client. |
| The request is larger than what the server is able to process. |
| The URI provided in the request is too long for the server to process. This is often used when too much data has been encoded into the URI of a |
| The client provided data with a media type that the server does not support. |
| The client has asked for a portion of the resource but the server cannot supply that portion. |
| The server cannot meet the requirements of the Expect request-header field. |
| The request was formatted correctly but cannot be processed in its current form. Often used when the specified parameters fail validation errors. WebDAV - RFC 4918 |
| The requested resource was found but has been locked and will not be returned. WebDAV - RFC 4918 |
| The request failed due to a failure of a previous request. WebDAV - RFC 4918 |
| The client should repeat the request using an upgraded protocol such as TLS 1.0. |
5xx Server Error
Http Status Codes Cheat Sheet 2020
| A generic status for an error in the server itself. |
| The server cannot respond to the request. This usually implies that the server could possibly support the request in the future — otherwise a |
| The server is acting as a proxy and did not receive an acceptable response from the upstream server. |
| The server is down and is not accepting requests. |
| The server is acting as a proxy and did not receive a response from the upstream server. |
| The server does not support the HTTP protocol version specified in the request. |
| Transparent content negotiation for the request results in a circular reference. |
| The user or server does not have sufficient storage quota to fulfill the request. WebDAV - RFC 4918 |
| The server detected an infinite loop in the request. WebDAV - RFC 5842 |
| Further extensions to the request are necessary for it to be fulfilled. |
| The client must authenticate with the network before sending requests. |
Notes
Httpstatuses
- Based on cheat.errtheblog.com and List of HTTP status codes on Wikipedia.