How does the Web work?

11
How does the web work? aka HTTP 101 by Guilherme Cavalcanti @guiocavalcanti

Transcript of How does the Web work?

Page 1: How does the Web work?

How does the web work?aka HTTP 101

by Guilherme Cavalcanti@guiocavalcanti

Page 2: How does the Web work?

Schedule

1. Some Web Principles2. REST3. HTTP

VerbsIdempotencySide effectsGET and POST Vs. PUT and DELETE

4. Rails5. AJAX vs. Accessibility

Page 3: How does the Web work?

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.

Page 4: How does the Web work?

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

Page 5: How does the Web work?

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

Page 6: How does the Web work?

HTTP Verbs

Idempotent Cacheable Side effects

GET x x

POST x

PUT x x

DELETE x

Page 7: How does the Web work?

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

Page 8: How does the Web work?

HTTP: RESTful services vs lack of verbs

Doesn't work on6

< HTML 4< XHTML 1.0

It works onXMLHttpRequests (aka AJAX)3

Page 9: How does the Web work?

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

Page 10: How does the Web work?

How Rails deals with it?

Edit: