200, 404, 302. Is it a lock combination? A phone number? No, they're HTTP status codes! As we develop Web applications, we encounter these status codes and others, and often we make decisions about which ones to return without giving much thought to their meaning or context. It's time to take a deeper look at HTTP. Knowing the methods, headers, and status codes, what they mean, and how to use them can help you develop richer Internet applications. Join Ben Ramsey as he takes you on a journey through RFC 2616 to discover some of the gems of HTTP.
14. Safe methods
â GET & HEAD should not take action
other than retrieval
â These are considered safe
â Allows agents to represent POST, PUT, &
DELETE in a special way
15. Idempotence
â Side-effects of N > 0 identical requests is
the same as for a single request
â GET, HEAD, PUT and DELETE share this
property
â OPTIONS and TRACE are inherently
idempotent
17. GET
â Retrieval of information
â Transfers a representation of a resource
from the server to the client
â Safe
â Idempotent
18. HEAD
â Identical to GET, except...
â Returns only the headers, not the body
â Useful for getting details about a
resource representation before retrieving
the full representation
â Safe
â Idempotent
19. POST
â The body content should be accepted as
a new subordinate of the resource
â Append, annotate, paste after
â Not safe
â Non-idempotent
20. PUT
â Opposite of GET
â Storage of information
â Transfers a representation of a resource
from the client to the server
â Not safe
â Idempotent
21. DELETE
â Requests that the resource identiïŹed be
removed from public access
â Not safe
â Idempotent
27. 1. Client sends a request without a body
and includes the Expect: 100-continue
header and all other headers
2. Server determines whether it will accept
the request and responds with 100
Continue (or a 4xx code on error)
3. Client sends the request again with the
body and without the Expect header
39. 204 No Content
2
HTTP/1.x 204 No Content
Date: Thu, 21 May 2009 23:28:34 GMT
40. 205 Reset Content
âThe server has fulïŹlled the request and
the user agent SHOULD reset the
document view which caused the request
to be sent. This response is primarily
intended to allow input for actions to take
place via user input, followed by a clearing
of the form in which the input is given so
that the user can easily initiate another
input action.â
41. 206 Partial Content
â Used when requests are made for
ranges of bytes from a resource
â Determine whether a server supports
range requests by checking for the
Accept-Ranges header with HEAD
47. 303 See Other
â The response to your request can be
found at another URL identiïŹed by the
Location header
â The client should make a GET request
on that URL
â The Location is not a substitute for this
URL
48. 307 Temporary
Redirect
â The resource resides temporarily at the
URL identiïŹed by the Location
â The Location may change, so donât
update your links
â If the request is not GET or HEAD, then
you must allow the user to conïŹrm the
action
49. 302 Found
â The resource has been found at another
URL identiïŹed by the Location header
â The new URL might be temporary, so the
client should continue to use this URL
â Redirections SHOULD be conïŹrmed by
the user (in practice, browsers donât
respect this)
50. 301 Moved
Permanently
â The resource has moved permanently to
the URL indicated by the Location
header
â You should update your links accordingly
â Great for forcing search engines, etc. to
index the new URL instead of this one
58. [bramsey@pippin ~] telnet phparch.com 80
Trying 64.34.173.96...
Connected to phparch.com.
Escape character is '^]'.
59. [bramsey@pippin ~] telnet phparch.com 80
Trying 64.34.173.96...
Connected to phparch.com.
Escape character is '^]'.
HEAD / HTTP/1.1
Host: phparch.com
60. [bramsey@pippin ~] telnet phparch.com 80
Trying 64.34.173.96...
Connected to phparch.com.
Escape character is '^]'.
HEAD / HTTP/1.1
Host: phparch.com
HTTP/1.1 200 OK
Date: Thu, 21 May 2009 21:01:06 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.5 mod_ssl/2.2.9
OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.5
Set-Cookie: PHPSESSID=eeeff50d3b6ae241c934a5c2671b0005;
expires=Sun, 21 Jun 2009 21:01:07 GMT; path=/;
domain=.phparch.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Connection closed by foreign host.
63. Questions?
â Slides posted at benramsey.com
â Rate this talk at joind.in/213
â Read the HTTP spec at
tools.ietf.org/html/rfc2616
â My company is Schematic
schematic.com