Skip to content

Commit

Permalink
bits and bobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Pilgrim committed Jun 3, 2009
1 parent 58f6340 commit 7fad5e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ SetOutputFilter DEFLATE
Header unset Vary
Header add Vary Accept-Encoding

Redirect /examples/feed-302.xml http://diveintopython3.org/examples/feed.xml
Redirect permanent /examples/feed-301.xml http://diveintopython3.org/examples/feed.xml
24 changes: 23 additions & 1 deletion http-web-services.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>HTTP Web Services</h1>
<h2 id=divingin>Diving In</h2>
<p class=f>HTTP web services are programmatic ways of sending and receiving data from remote servers using nothing but the operations of <abbr>HTTP</abbr>. If you want to get data from the server, use <abbr>HTTP</abbr> <code>GET</code>; if you want to send new data to the server, use <abbr>HTTP</abbr> <code>POST</code>. Some more advanced <abbr>HTTP</abbr> web service <abbr>API</abbr>s also define ways of modifying existing data and deleting data, using <abbr>HTTP</abbr> <code>PUT</code> and <abbr>HTTP</abbr> <code>DELETE</code>. In other words, the &#8220;verbs&#8221; built into the <abbr>HTTP</abbr> protocol (<code>GET</code>, <code>POST</code>, <code>PUT</code>, and <code>DELETE</code>) map directly to application-level operations for retrieving, creating, modifying, and deleting data.

<p>The main advantage of this approach is simplicity, and its simplicity has proven popular with a lot of different sites. Data &mdash; usually <abbr>XML</abbr> data &mdash; can be built and stored statically, or generated dynamically by a server-side script, and all major programming languages (including Python, of course!) include an <abbr>HTTP</abbr> library for downloading it. Debugging is also easier; because each &#8220;call&#8221; to the web service had a unique <abbr>URL</abbr>, you can load it in your web browser and immediately see the raw data.
<p>The main advantage of this approach is simplicity, and its simplicity has proven popular. Data &mdash; usually <abbr>XML</abbr> data &mdash; can be built and stored statically, or generated dynamically by a server-side script, and all major programming languages (including Python, of course!) include an <abbr>HTTP</abbr> library for downloading it. Debugging is also easier; because each &#8220;call&#8221; to the web service had a unique <abbr>URL</abbr>, you can load it in your web browser and immediately see the raw data.

<p>Examples of <abbr>HTTP</abbr> web services:
<ul>
Expand Down Expand Up @@ -446,6 +446,28 @@ <h3 id=httplib2-compression>How <code>http2lib</code> Handles compression</h3>

<p>FIXME

<pre class=screen>
<samp class=p>>>> </samp><kbd>response, content = h.request('http://diveintopython3.org/')</kbd>
<samp>connect: (diveintopython3.org, 80)
send: b'GET / HTTP/1.1
Host: diveintopython3.org
<mark>accept-encoding: deflate, gzip</mark>
user-agent: Python-httplib2/$Rev: 259 $'
reply: 'HTTP/1.1 200 OK'</samp>
<samp class=p>>>> </samp><kbd>print(dict(response.items()))</kbd>
<samp>{<mark>'-content-encoding': 'gzip',</mark>
'accept-ranges': 'bytes',
'connection': 'close',
'content-length': '6657',
'content-location': 'http://diveintopython3.org/',
'content-type': 'text/html',
'date': 'Tue, 02 Jun 2009 03:26:54 GMT',
'etag': '"7f806d-1a01-9fb97900"',
'last-modified': 'Tue, 02 Jun 2009 02:51:48 GMT',
'server': 'Apache',
'status': '304',
'vary': 'Accept-Encoding,User-Agent'}</samp></pre>

<h3 id=httplib2-redirects>How <code>httplib2</code> Handles redirects</h3>

<p>FIXME
Expand Down
1 change: 1 addition & 0 deletions where-to-go-from-here.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h2 id=code>Where To Look For Python 3-Compatible Code</h2>

<ul>
<li><a href="http://pypi.python.org/pypi?:action=browse&amp;c=533&amp;show=all">Python Package Index: list of Python 3 packages</a>
<li><a href="http://code.activestate.com/recipes/langs/python/tags/python3/">Python Cookbook: list of recipes tagged &#8220;python3&#8221;</a>
<li><a href="http://code.google.com/hosting/search?q=label:python3">Google Project Hosting: list of projects tagged &#8220;python3&#8221;</a>
<li><a href="http://sourceforge.net/search/?words=%22python+3%22">SourceForge: list of projects matching &#8220;Python 3&#8221;</a>
<li><a href="http://github.com/search?type=Repositories&amp;language=python&amp;q=python3">GitHub: list of projects matching &#8220;python3&#8221;</a> (also, <a href="http://github.com/search?type=Repositories&amp;language=python&amp;q=python+3">list of projects matching &#8220;python 3&#8221;</a>)
Expand Down

0 comments on commit 7fad5e6

Please sign in to comment.