Skip to content

Instantly share code, notes, and snippets.

@DJTB
Last active March 8, 2017 20:46
Show Gist options
  • Save DJTB/9c11d485c3f9f2a6e66d3b08d20a876a to your computer and use it in GitHub Desktop.
Save DJTB/9c11d485c3f9f2a6e66d3b08d20a876a to your computer and use it in GitHub Desktop.
HTTP Notes

HTTP Notes

Status Codes

2xx - success
200 - served!
201 - ok, created new resource (includes location header)
202 - ok, but not yet complete/in process (a long(ish) process -> github fork)
204 - yes, but no other relevant content to be returned
206 - yes, but partial response (binary content like images, includes content-range header of which bytes were returned)

3xx - resource is somewhere else!
301 - moved! (for get requests, can follow redirect - includes location header for new address)
304 - not modified (use browser cache!)
307 - moved! (for post requests, can follow redirect)

4xx - Client errors. Should be possible to fix or remedy by the user/developer.
400 - bad request (wrong/malformed content type [eg. form-encoded instead of json])
401 - auth required (protected route)
403 - forbidden (might need auth, or required headers are missing perhaps)
404 - not found (wrong/malformed url)

5xx - Server errors. Cannot be remedied by the user/developer.
500 - general server error
503 - server unavailable (rebooting, too many requests)

Methods

GET - Request resource.

POST - Request the resource process the included request message body representation according to resource specific semantics. HTTP POST is loosely defined by definition, and can be used in many different scenarios, such as creating a new resource based on the request representation, appending data to an existing representation, or generic processing of an HTML form submission.

PATCH - Make modifications to existing resources. Designed for "partial updates", as opposed to replacing an entire resource using HTTP PUT.

DELETE - Request that the server perform a delete operation on the specified resource with resource specific semantics. Behind the scenes, the delete operation may result in a removal of a file from the filesystem, or an update to the database to reflect the change. Can even be successful if resource didn't exist to begin with.

OPTIONS - Request information about the communication options available for the target resource. The response may include an Allow header indicating allowed HTTP methods on the resource, or various Cross Origin Resource Sharing headers. The HTTP OPTIONS method is both safe and idempotent, as it is intended only for use in querying information about ways to interact with a resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment