Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HTTP and Your Angry Dog

HTTP and Your Angry Dog

As presented at Whisky Web, Confoo, PFCongres and Fronteers User Group. An overview of some intermediate level HTTP features and how they might be useful in practice.

Ross Tuck

April 13, 2013
Tweet

More Decks by Ross Tuck

Other Decks in Programming

Transcript

  1. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request
  2. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request 2 Parts
  3. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request The body
  4. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <title>My application</title> ... Request The body
  5. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request The body
  6. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request
  7. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request The headers
  8. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request The good stuff
  9. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request
  10. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request GET, POST, PUT, DELETE
  11. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request Relative URL HTTP version
  12. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request Key/Value pairs
  13. POST /gists HTTP/1.1 Authorization: Basic xxxxxxxx Host: api.github.com Content-Length: 146

    { "description": "the description for this gist", "public": false, "files": { ... Request
  14. HTTP/1.1 201 Created Date: Sun, 09 Sep 2012 11:42:41 GMT

    Content-Length: 1848 Location: https://api.github.com/gists/a43a0cf58 { "description": "the description for this gist", "comments": 0, "created_at": "2012-09-09T11:42:40Z", ... Response Status code
  15. • 2xx • 3xx • 4xx • 5xx OK! Over

    there! Client screwed up! Server screwed up!
  16. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    { "cute": true, "big": false, "data_dog": true } Response
  17. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    <dog breed="corgi"> <cute>true</cute> <data capacity="on" /> </dog> Response
  18. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    Content-Type: application/json { "cute": true, "big": false, "data_dog": true } Response
  19. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    Content-Type: application/json Vary: Accept {“json”: “omgz”} Response
  20. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    Content-Type: application/json Vary: Accept {“json”: “omgz”} Response
  21. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    Content-Type: application/json Vary: Accept, User-Species {“json”: “omgz”} Response
  22. HTTP/1.1 200 OK Date: Sun, 26 Aug 2012 18:00:43 GMT

    Content-Type: application/json Vary: Accept, User-Species {“json”: “dogs rule, cats drool”} Response
  23. HTTP/1.1 200 OK Expires: Thu, 07 Feb 2013 22:00:00 GMT

    {“herp”: “derp”} Response
  24. HTTP/1.1 200 OK Server: nginx/1.0.13 Date: Sun, 26 Aug 2012

    18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" "history": [ { "version": "529f6311d5518977534b6e1fd313...", ... Response
  25. ... "user": { "gravatar_id": "c26bfcbd5f786591e036fa0", "avatar_url": "https://secure.gravatar...", "login": "rosstuck", "url":

    "https://api.github.com/users/rosstuck", "id": 146766 }, "change_status": { "additions": 1, "deletions": 0, "total": 1 }, Response
  26. "url": "https://api.github.com/gists/348...", "committed_at": "2012-08-26T17:40:03Z" } ], "git_pull_url": "git://gist.github.com/34819...", "forks": [

    ], "html_url": "https://gist.github.com/3481910", "git_push_url": "[email protected]:3481910.git", "comments": 0, "user": { Response
  27. HTTP/1.1 200 OK Server: nginx/1.0.13 Date: Sun, 26 Aug 2012

    18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" { "history": [ { "version": "529f6311d5518970903cb5427534b6e1fd313aca", "user": { "gravatar_id": "c26bfcbd5f786591e036fa0958a11e8b", "avatar_url": "https://secure.gravatar.com/avatar/c26bfcbd5f786591e036fa0958a11e8b?d=https://a2... "login": "rosstuck", "url": "https://api.github.com/users/rosstuck", "id": 146766 }, "change_status": { "additions": 1, "deletions": 0, "total": 1 }, "url": "https://api.github.com/gists/3481910/529f6311d5518970903cb5427534b6e1fd313aca", "committed_at": "2012-08-26T17:40:03Z" } ], "git_pull_url": "git://gist.github.com/3481910.git", Response "forks": [ ], "html_url": "https://gist.github.com/3481910", "git_push_url": "[email protected]:3481910.git", "comments": 0, "user": { "gravatar_id": "c26bfcbd5f786591e036fa0958a11e8b", "avatar_url": "https://secure.gravatar.com/avatar/c26bfcbd5f78659....",} "login": "rosstuck", "url": "https://api.github.com/users/rosstuck", "id": 146766 }, "public": true, "created_at": "2012-08-26T17:40:03Z", "files": { "gistfile1.txt": { "type": "text/plain", "filename": "gistfile1.txt", "raw_url": "https://gist.github.com/raw/3481910/8b6946739e8098408ee3af96... "content": "Hello PFC!", "language": null, "size": 10 } }, "description": "", "url": "https://api.github.com/gists/3481910", "updated_at": "2012-08-26T17:40:03Z", "id": "3481910" }
  28. HTTP/1.1 304 Not Modified Server: nginx/1.0.13 Date: Sun, 26 Aug

    2012 18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" Response
  29. HTTP/1.1 304 Not Modified Server: nginx/1.0.13 Date: Sun, 26 Aug

    2012 18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" Response
  30. HTTP/1.1 304 Not Modified Server: nginx/1.0.13 Date: Sun, 26 Aug

    2012 18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" Response No giant body!
  31. HTTP/1.1 200 OK Server: nginx/1.0.13 Date: Sun, 26 Aug 2012

    18:00:43 GMT Vary: Accept ETag: "f4e15911542b92b44bb38186e71cc8f5" "history": [ { "version": "529f6311d5518977534b6e1fd313...", Response
  32. Response HTTP/1.1 200 OK Server: nginx/1.0.13 Date: Sat, 01 Sep

    2012 14:01:38 GMT ETag: "899b76047a5e68445668374c2e0faa32" { "description": "cheese om nom nom", "user": { "login": "rosstuck", ...