Slideshow transcript
Slide 1: Cocoa + HTTP http://you.down.wi.th/rpc?you=know+me Jonathan ‘Wolf’ Rentzsch http://rentzsch.com PSIG 115 Red Shed Software better necessarily means different
Slide 2: HTTP • Not just “Hypertext”: general transport protocol • simple • efficient (binary-clean) • widespread • extensible • standard authentication, crypto, RPC, unicode, etc Red Shed Software better necessarily means different
Slide 3: Downsides • Not really connection-oriented (stateless) • work-arounds: cookies, Comet • GET vs POST vs REST • “Representational State Transfer" • URL-encoding vs Form-data (MIME); XML vs JSON • BEEP would andgreat butcomplicated as be it’s not nearly widespread is more Red Shed Software better necessarily means different
Slide 4: Client-side • curl • Core Foundation • NSURLHandle (CURLHandle) • DDCurl • NSURLConnection (NSURLRequest+postForm) • Python, Ruby, etc Red Shed Software better necessarily means different
Slide 5: Server-side • CFHTTP • JRHTTPServer • ToxicHTTP • TouchHTTPD • Apple’s CocoaHTTPServer • Cultured Code’s SimpleHTTPServer • Deusty Designs’ CocoaHTTPServer (auth, ssl) Red Shed Software better necessarily means different
Slide 6: RPC with GET • GET (URL-encoded query string) http://example.com/action.php?foo=bar • “URL-encoded” == percent-escaping http://example.com/action.php?foo=bar%20baz http://example.com/action.php?foo=bar+baz Red Shed Software better necessarily means different
Slide 7: GET On-the-wire • GET /action.php?foo=bar HTTP/1.1 HOST: example.com • HTTP/1.1 200 Ok ... Red Shed Software better necessarily means different
Slide 8: RPC with POST • Like GET, but places parameters into HTTP body • Large payloads (upload gigs of data) • Choice of encoding of parameters • URL-encoded (percent-encoding like GET) • Form-data (MIME stuff) Red Shed Software better necessarily means different
Slide 9: POST On-the-wire • GET /action.php HTTP/1.1 HOST: example.com Content-Type: application/x-www-form-urlencoded foo=bar%20baz • HTTP/1.1 200 Ok ... Red Shed Software better necessarily means different
Slide 10: POST On-the-wire • GET /action.php HTTP/1.1 HOST: example.com Content-Type: multipart/form-data; boundary=XXX --XXX Content-Disposition: form-data; name="foo" Content-Type: text/plain; charset=utf-8 bar --XXX-- Red Shed Software better necessarily means different
Slide 11: RPC with REST • Leverages Standard HTTP Methods • POST => Create • PUT => Update • DELETE => Delete • POST to http://example.com/widgets • PUT to http://example.com/widgets/42 • DELETE http://example.com/widgets/42 Red Shed Software better necessarily means different
Slide 12: REST On-the-wire • POST example.com /widgets HTTP/1.1 Host: <?xml version="1.0"?> <widget> <name>fred</name> </widget> • HTTP/1.1 201 Created ... Location: /widgets/42 Red Shed Software better necessarily means different
Slide 13: REST On-the-wire • PUT /widgets/42 HTTP/1.1 Host: example.com <?xml version="1.0"?> <widget> <name>wilma</name> </widget> • HTTP/1.1 200 Ok ... Red Shed Software better necessarily means different
Slide 14: REST On-the-wire • DELETE /widgets/42 HTTP/1.1 Host: example.com • HTTP/1.1 200 Ok ... Red Shed Software better necessarily means different
Slide 15: demo Red Shed Software better necessarily means different



Add a comment on Slide 1
If you have a SlideShare account, login to comment; else you can comment as a guest- Favorites & Groups
Showing 1-50 of 0 (more)