Transcript
Page 1: HTTP and Your Angry Dog

HTTP

ZendCon 2014

& Your Angry Dog

Ross Tuck

Page 2: HTTP and Your Angry Dog

Freerange CodemonkeyKnow-It-All

Hot-Air Balloon

Page 4: HTTP and Your Angry Dog

Today's topic:

Page 5: HTTP and Your Angry Dog

Dogs

Page 6: HTTP and Your Angry Dog
Page 7: HTTP and Your Angry Dog
Page 8: HTTP and Your Angry Dog
Page 9: HTTP and Your Angry Dog
Page 10: HTTP and Your Angry Dog

HTTP & Dogs

Page 11: HTTP and Your Angry Dog
Page 12: HTTP and Your Angry Dog
Page 13: HTTP and Your Angry Dog
Page 14: HTTP and Your Angry Dog
Page 15: HTTP and Your Angry Dog

The Agenda

Page 16: HTTP and Your Angry Dog

Basics

Page 17: HTTP and Your Angry Dog

Client Server

Request

Response

Page 18: HTTP and Your Angry Dog

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

Page 19: HTTP and Your Angry Dog

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

Page 20: HTTP and Your Angry Dog

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

Page 21: HTTP and Your Angry Dog

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

Page 22: HTTP and Your Angry Dog

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

Page 23: HTTP and Your Angry Dog

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

Page 24: HTTP and Your Angry Dog

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

Page 25: HTTP and Your Angry Dog

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 stuf

Page 26: HTTP and Your Angry Dog

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

Page 27: HTTP and Your Angry Dog

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

Page 28: HTTP and Your Angry Dog

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 URLHTTP version

Page 29: HTTP and Your Angry Dog

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

Page 30: HTTP and Your Angry Dog

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

Page 31: HTTP and Your Angry Dog
Page 32: HTTP and Your Angry Dog

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",

...

ResponseStatus code

Page 33: HTTP and Your Angry Dog
Page 34: HTTP and Your Angry Dog

• 2xx

• 3xx

• 4xx

• 5xx

OK!

Over there!

Client screwed up!

Server screwed up!

Page 35: HTTP and Your Angry Dog

Content Negotiation

Page 36: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Request

Page 37: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Date: Sun, 26 Aug 2012 18:00:43 GMT

{

"cute": true,

"big": false,

"data_dog": true

}

Response

Page 38: HTTP and Your Angry Dog

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

Page 39: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Request

Page 40: HTTP and Your Angry Dog

GET /dogs/corgi.json HTTP/1.1

Host: api.example.com

Request

Page 41: HTTP and Your Angry Dog

/dogs/corgi.json !== /dogs/corgi.xml

Page 42: HTTP and Your Angry Dog

Imagine the URL as your primary key.

Page 43: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Request

Page 44: HTTP and Your Angry Dog

GET /dogs/corgi?_format=json HTTP/1.1

Host: api.example.com

Request

Page 45: HTTP and Your Angry Dog

POST /dogs/corgi?_format=json HTTP/1.1

Host: api.example.com

Request

Page 46: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Request

Page 47: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json

Request

Page 48: HTTP and Your Angry Dog

More POWAH

Page 49: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json

Request

Page 50: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json, application/xml

Request

How do I choose?

Page 51: HTTP and Your Angry Dog
Page 52: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json, application/xml

Request

Page 53: HTTP and Your Angry Dog

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

Page 54: HTTP and Your Angry Dog

Nifty.

Page 55: HTTP and Your Angry Dog

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json, application/xml

Request

Page 56: HTTP and Your Angry Dog

text/html, text/plain

Page 57: HTTP and Your Angry Dog

text/html;key=value, text/plain

Page 58: HTTP and Your Angry Dog

text/html;key=value;foo=bar, text/plain

Page 59: HTTP and Your Angry Dog

text/html, text/plain

Page 60: HTTP and Your Angry Dog

text/html, text/plain;q=0.5

Quality(Default 1.0)

Page 61: HTTP and Your Angry Dog

text/html, text/plain;q=0.5, text/*;q=0.1

Wildcards

Page 62: HTTP and Your Angry Dog

text/html, text/plain;q=0.5, */*;q=0.1

Anything at all

Page 63: HTTP and Your Angry Dog

Accept HeadersLittle weird...

Page 64: HTTP and Your Angry Dog

But not so scary.

Page 65: HTTP and Your Angry Dog

text/html,application/xhtml+xml,

application/xml;q=0.9,*/*;q=0.8

Page 66: HTTP and Your Angry Dog

Cool...

Page 67: HTTP and Your Angry Dog

What the heck is it good for?

Page 68: HTTP and Your Angry Dog

Accept is a “Pattern”

Page 69: HTTP and Your Angry Dog

Accept-LanguageAccept-EncodingAccept-CharsetAccept-Ranges

Page 70: HTTP and Your Angry Dog

Content-LanguageContent-Encoding(works differently)

Content-Range

Page 71: HTTP and Your Angry Dog

Resource vs Representation

/dog/corgi

JSON, Dutch,Gzipped,/dog/corgi

Page 72: HTTP and Your Angry Dog

Resource vs Representation

Page 73: HTTP and Your Angry Dog

Best way to version your API.

Arguably.Right now.

Page 74: HTTP and Your Angry Dog

/v1/dogs/corgi

Page 75: HTTP and Your Angry Dog

Accept: application/vnd.dogipedia-v1+json

Page 76: HTTP and Your Angry Dog

Accept: application/vnd.dogipedia-v2+json

Page 77: HTTP and Your Angry Dog
Page 78: HTTP and Your Angry Dog
Page 79: HTTP and Your Angry Dog

Vary

Page 80: HTTP and Your Angry Dog

Client Server

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Page 81: HTTP and Your Angry Dog

Client Server

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Page 82: HTTP and Your Angry Dog

Client ServerProxy

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Page 83: HTTP and Your Angry Dog

Client ServerProxy

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json, text/plain

User-Species: cat

Page 84: HTTP and Your Angry Dog

Same URL.Different output.

WTF should I return?

Page 85: HTTP and Your Angry Dog

Client ServerProxy

GET /dogs/corgi HTTP/1.1

Host: api.example.com

Accept: application/json, text/plain

User-Species: cat

Page 86: HTTP and Your Angry Dog

Client ServerProxy

Page 87: HTTP and Your Angry Dog

Here's how.

Hint:Involves theVary header!

Page 88: HTTP and Your Angry Dog

Client ServerProxy

/dogs/corgiAccept: application/json, text/plainUser-Species: cat

Page 89: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Date: Sun, 26 Aug 2012 18:00:43 GMT

Content-Type: application/json

Vary: Accept

{“json”: “omgz”}

Response

Page 90: HTTP and Your Angry Dog

Client ServerProxy

URL and Accept?Okay, I got this.

Page 91: HTTP and Your Angry Dog

Some time later...

Page 92: HTTP and Your Angry Dog

Client ServerProxy

/dogs/corgiAccept: application/json, text/plainUser-Species: aardvark

Page 93: HTTP and Your Angry Dog

Client ServerProxy

Valid cache.I has it.

Page 94: HTTP and Your Angry Dog

Client ServerProxy

ZZ ZZZ

Z

Page 95: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Date: Sun, 26 Aug 2012 18:00:43 GMT

Content-Type: application/json

Vary: Accept

{“json”: “omgz”}

Response

Page 96: HTTP and Your Angry Dog

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

Page 97: HTTP and Your Angry Dog

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

Page 98: HTTP and Your Angry Dog

Request headers.Not Response!

Page 99: HTTP and Your Angry Dog

Bad Reputation?2 Reasons

Page 100: HTTP and Your Angry Dog

1. Accept-Encoding -Language

Page 101: HTTP and Your Angry Dog

2. Internet Explorer

Page 102: HTTP and Your Angry Dog

Caching

Page 103: HTTP and Your Angry Dog

ExpiresPragma

Cache-Control

Page 104: HTTP and Your Angry Dog

ExpiresPragma

Cache-Control

Page 105: HTTP and Your Angry Dog

Expires

Cache-Control

HTTP 1.0

HTTP 1.1

Page 106: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Expires: Wed, 29 Oct 2014 22:00:00 GMT

{“herp”: “derp”}

Response

Page 107: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Cache-Control: max-age=120

{“herp”: “derp”}

Response

Page 108: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Cache-Control: max-age=120

Response

Page 109: HTTP and Your Angry Dog

Expires

Cache-Control

HTTP 1.0

HTTP 1.1

Page 110: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Cache-Control: max-age=120

{“herp”: “derp”}

Response

Page 111: HTTP and Your Angry Dog

HTTP/1.1 200 OK

Cache-Control: max-age=120, s-maxage=120

{“herp”: “derp”}

Response

Dude, Where's my dash?

Page 112: HTTP and Your Angry Dog

publicprivate

no-storeno-cache

no-transform

must-revalidateproxy-revalidate

Page 113: HTTP and Your Angry Dog

Mark Nottingham's Caching Tutorialhttp://www.mnot.net/cache_docs/

Much better than me.

Page 114: HTTP and Your Angry Dog

Conditional Requests

Page 115: HTTP and Your Angry Dog

Conditional Requests

Page 116: HTTP and Your Angry Dog

The Part About ETags

Page 117: HTTP and Your Angry Dog

Conditional Requests

Page 118: HTTP and Your Angry Dog

DELETE /ross/reputation HTTP/1.1

Host: api.joind.in

If-Talk-Quality: Crap

Request

Page 119: HTTP and Your Angry Dog

if ($talkQuality === 'Crap') {

delete($rossReputation);

}

Not real code

Server

Page 120: HTTP and Your Angry Dog

What kind of conditions?

Page 121: HTTP and Your Angry Dog

If-MatchIf-None-Match

If-Modified-SinceIf-Unmodified-Since

If-Range

ETags

Datetimes

Either

Page 122: HTTP and Your Angry Dog

Wait a second, Ross.

Audience

Page 123: HTTP and Your Angry Dog

What the heck is an ETag?

Page 124: HTTP and Your Angry Dog

A string.Any string.

Page 125: HTTP and Your Angry Dog

One rule:

Page 126: HTTP and Your Angry Dog

Represent the current state.

Page 127: HTTP and Your Angry Dog

“14”“a381bedb5d4478053eb04be35f8798dd”

“winnie-the-pooh”

Page 128: HTTP and Your Angry Dog

...for the current representation.

Page 129: HTTP and Your Angry Dog

etag(“v14-json-en”) !== etag(“v14-xml-en”)

Don't cross the streams

Server

Page 130: HTTP and Your Angry Dog

Last Modified Date sounds easier...

Audience

Page 131: HTTP and Your Angry Dog

Wed, 15 Nov 1995 04:58:08 GMT

One second of precision

Page 132: HTTP and Your Angry Dog

Caching With Conditionals

Page 133: HTTP and Your Angry Dog

Use Case

Page 134: HTTP and Your Angry Dog

GET /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

Request

Page 135: HTTP and Your Angry Dog

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

Page 136: HTTP and Your Angry Dog

...

"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

Page 137: HTTP and Your Angry Dog

"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

Page 138: HTTP and Your Angry Dog
Page 139: HTTP and Your Angry Dog

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"

}

Page 140: HTTP and Your Angry Dog
Page 141: HTTP and Your Angry Dog

GET /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-None-Match: "f4e15911542b92b44bb38186e71cc8f5"

Request

Page 142: HTTP and Your Angry Dog

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

Page 143: HTTP and Your Angry Dog

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

Page 144: HTTP and Your Angry Dog

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!

Page 145: HTTP and Your Angry Dog

Caching.You has it.

Page 146: HTTP and Your Angry Dog

GET /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-None-Match: "a381bedb5d4478053eb04be35f8798dd"

Request

Page 147: HTTP and Your Angry Dog

GET /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-None-Match: "ross-is-a-poo-poo-head"

Request

Page 148: HTTP and Your Angry Dog

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

Page 149: HTTP and Your Angry Dog

Recap

Page 150: HTTP and Your Angry Dog

No ETag Old ETag Matching ETag

Full BodyFull BodyNo Body

Page 151: HTTP and Your Angry Dog

...on supported servers.

Page 152: HTTP and Your Angry Dog

Why?

Page 153: HTTP and Your Angry Dog

ParsingBandwidth

Response time

Probably

.Maybe

Page 154: HTTP and Your Angry Dog

However...

Page 155: HTTP and Your Angry Dog

“The fastest request is one you don't make.”

- Jesus

Page 156: HTTP and Your Angry Dog

More Fun With ETags

Page 157: HTTP and Your Angry Dog

Optimistic Concurrency Control

“Record Versioning”

Page 158: HTTP and Your Angry Dog

Request

Page 159: HTTP and Your Angry Dog

GET /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-None-Match: "f4e15911542b92b44bb38186e71cc8f5"

Request

Page 160: HTTP and Your Angry Dog

PATCH /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-None-Match: "f4e15911542b92b44bb38186e71cc8f5"

Request

Page 161: HTTP and Your Angry Dog

PATCH /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-Match: "f4e15911542b92b44bb38186e71cc8f5"

Request

Page 162: HTTP and Your Angry Dog

PATCH /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-Match: "f4e15911542b92b44bb38186e71cc8f5"

{ "description": "cheese om nom nom" }

Request

Page 163: HTTP and Your Angry Dog

Response

Page 164: HTTP and Your Angry Dog

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",

...

Page 165: HTTP and Your Angry Dog

It works.

Page 166: HTTP and Your Angry Dog

So what?

Page 167: HTTP and Your Angry Dog

What if I send something...

Page 168: HTTP and Your Angry Dog
Page 169: HTTP and Your Angry Dog

PATCH /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-Match: "899b76047a5e68445668374c2e0faa32"

{ "description": "cheese om nom nom" }

Request

Page 170: HTTP and Your Angry Dog

PATCH /gists/3481910 HTTP/1.1

Host: api.github.com

Accept: */*

If-Match: "stay-puft-marshmellow-dog!"

{ "description": "cheese om nom nom" }

Request

Page 171: HTTP and Your Angry Dog

HTTP/1.1 412 Precondition Failed

Server: nginx/1.0.13

Date: Sun, 26 Aug 2012 18:00:43 GMT

Response

Page 172: HTTP and Your Angry Dog

Response

Page 173: HTTP and Your Angry Dog

if (“stay-puft-marshmellow-dog” == “f4e1591..”) {

patchTheRecord();

}

Server

Page 174: HTTP and Your Angry Dog

if (“stay-puft-marshmellow-dog” == “f4e1591..”) {

patchTheRecord();

} else {

sendScary412Message();

}

Server

Page 175: HTTP and Your Angry Dog

Your ETag is out of date.

Page 176: HTTP and Your Angry Dog

“Two guys on the same record” problem

Page 177: HTTP and Your Angry Dog

Scary Precondition Error pt. 2

Page 178: HTTP and Your Angry Dog

DisclaimerNew Stuff Ahead

Page 179: HTTP and Your Angry Dog

DELETE /gists/3481910 HTTP/1.1

Host: api.github.com

Request

Page 180: HTTP and Your Angry Dog

HTTP/1.1 428 Precondition Required

Server: nginx/1.0.13

Date: Sun, 26 Aug 2012 18:00:43 GMT

Response

Page 181: HTTP and Your Angry Dog

Am I operating on the latest version?

Page 182: HTTP and Your Angry Dog

DELETE /gists/3481910 HTTP/1.1

Host: api.github.com

Request

Page 183: HTTP and Your Angry Dog

DELETE /gists/3481910 HTTP/1.1

Host: api.github.com

If-Match: "f4e15911542b92b44bb38186e71cc8f5"

Request

Page 184: HTTP and Your Angry Dog

HTTP/1.1 204 No Content

Server: nginx/1.0.13

Date: Sun, 26 Aug 2012 18:00:43 GMT

Response

Page 185: HTTP and Your Angry Dog

Look before you leap.

Page 186: HTTP and Your Angry Dog

Tooling

Page 187: HTTP and Your Angry Dog
Page 188: HTTP and Your Angry Dog
Page 189: HTTP and Your Angry Dog
Page 190: HTTP and Your Angry Dog

Epilogue: HTTP & Dogs

Page 191: HTTP and Your Angry Dog

Content NegotiationVary

CachingPreconditions

Page 192: HTTP and Your Angry Dog

Treat it like your framework.

Page 193: HTTP and Your Angry Dog
Page 194: HTTP and Your Angry Dog
Page 195: HTTP and Your Angry Dog
Page 196: HTTP and Your Angry Dog
Page 197: HTTP and Your Angry Dog

Questions?

Page 198: HTTP and Your Angry Dog

Resources

• RFC 7231–Sections 4 - 7

• http://redbot.org/

• http://mnot.net/cache_docs/

• http://charlesproxy.com/

• http://guzzlephp.org/

Page 199: HTTP and Your Angry Dog

Image Credits• http://www.sxc.hu/photo/555539• http://www.flickr.com/photos/thedalogs/2953136078/• http://www.sxc.hu/photo/678952• http://www.flickr.com/photos/designgate/8317884432/• http://www.flickr.com/photos/barretthall/3289317664/• http://www.flickr.com/photos/binaryape/3702275400/lightbox/• http://www.flickr.com/photos/istolethetv/2956799679/in/photostream/• http://theflashbackspodcast.blogspot.nl/2012/01/30-day-film-challenge-day-8.html• http://www.flickr.com/photos/jonomueller/6906420190/• http://www.flickr.com/photos/cookbookman/6175752147• http://www.flickr.com/photos/creativedc/2913123330/• http://www.flickr.com/photos/epc/44053757/• http://www.flickr.com/photos/soggydan/4698849104/• http://www.flickr.com/photos/owldreams/4430175427/• http://www.flickr.com/photos/piddleville/2499539542/• http://www.flickr.com/photos/danja/5665671907/• http://www.flickr.com/photos/cradlehall/3574160744/• http://www.flickr.com/photos/ironypoisoning/7114801437/• http://www.flickr.com/photos/piddleville/2499539542/lightbox/• http://everydayidrawadog.blogspot.nl/2009_02_01_archive.html

Page 200: HTTP and Your Angry Dog

joind.in/12071

@rosstuck

Ross Tuckrosstuck.com


Top Related