How does the Web work?
-
Upload
guilherme -
Category
Technology
-
view
571 -
download
1
Transcript of How does the Web work?
How does the web work?aka HTTP 101
by Guilherme Cavalcanti@guiocavalcanti
Schedule
1. Some Web Principles2. REST3. HTTP
VerbsIdempotencySide effectsGET and POST Vs. PUT and DELETE
4. Rails5. AJAX vs. Accessibility
Some Web Principles
UniversalityAny resource anywhere can be given a URIAny resource of significance should be given a URI.
Resources are documentsAs well as concepts and abstract ideias (Semantic Web)
Global ScopeIt doesn't matter to whom or where you specify that URI, it will have the same meaning.
REST
Architectural style coined by Roy Fielding (phd dissertation)5
State transferenceAt any particular time, a client can either be in transition between application states or "at rest". A client in a rest state is able to interact with its user, but creates no load and consumes no per-client storage on the servers or on the network4
The HTTP portocols uses the rest style
HTTP Verbs
Side effectchange or not the state of the world
Idempotencythe side-effects of N > 0 identical requests is the same as for a single request
HTTP Verbs
Idempotent Cacheable Side effects
GET x x
POST x
PUT x x
DELETE x
HTTP: RESTful services vs lack of verbs
PUTPut ssomething at some placeUpdates somethingPUT http://redu.com.br/spaces/my-spaceContent: My new Space
POSTThe server decides which action gonna be takenPOST http://redu.com.br/spaces/filterContent: name=my;audience=[higher-edu,sat]
DELETEDeletes some resourceDELETE http://redu.com.br/spaces/my-space
HTTP: RESTful services vs lack of verbs
Doesn't work on6
< HTML 4< XHTML 1.0
It works onXMLHttpRequests (aka AJAX)3
HTTP: RESTful services vs lack of verbs
POST acting as PUTPOST http://redu.com.br/spacesContent: name=My Space;path=my-space
POST acting as PUT when updatingPOST http://redu.com.br/spaces/my-spaceContent: _method=PUT
POST acting as DELETEPOST http://redu.com.br/spaces/my-spaceContent: _method=DELETE
How Rails deals with it?
Edit:
References
1. Why put and delete?2. HTTP RFC3. Verbs support4. REST5. Roy's dissertation6. Useful question at Stackoverflow