Cocoa + HTTP
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Cocoa + HTTP

  • 7,333 views
Uploaded on

intro to client+server HTTP tech for Cocoa coders

intro to client+server HTTP tech for Cocoa coders

More in: Technology , Design
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
7,333
On Slideshare
7,312
From Embeds
21
Number of Embeds
1

Actions

Shares
Downloads
34
Comments
0
Likes
3

Embeds 21

http://www.slideshare.net 21

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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
  • 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
  • 3. Downsides • Not really connection-oriented (stateless) • work-arounds: cookies, Comet • GET vs POST vs REST • “Representational State Transferquot; • 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
  • 4. Client-side • curl • Core Foundation • NSURLHandle (CURLHandle) • DDCurl • NSURLConnection (NSURLRequest+postForm) • Python, Ruby, etc Red Shed Software better necessarily means different
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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=quot;fooquot; Content-Type: text/plain; charset=utf-8 bar --XXX-- Red Shed Software better necessarily means different
  • 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
  • 12. REST On-the-wire • POST example.com /widgets HTTP/1.1 Host: <?xml version=quot;1.0quot;?> <widget> <name>fred</name> </widget> • HTTP/1.1 201 Created ... Location: /widgets/42 Red Shed Software better necessarily means different
  • 13. REST On-the-wire • PUT /widgets/42 HTTP/1.1 Host: example.com <?xml version=quot;1.0quot;?> <widget> <name>wilma</name> </widget> • HTTP/1.1 200 Ok ... Red Shed Software better necessarily means different
  • 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
  • 15. demo Red Shed Software better necessarily means different