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