BitWorking

Joe Gregorio's writings (archives), projects and status updates.

!!!!! Httpcache will remain here, but going forward you should switch to using httplib2.

Httpcache

A caching http interface that supports ETags and gzip to conserve bandwidth. All of the headers and the content at that URL are cached for quick retrieval later. ETags are supported for doing a conditional GET, which only retrieves the content when it has really changed.

Usage

     cache = HTTPCache('http://127.0.0.1/testContent.xml')
     content = cache.content()

The 'content' is the content retrieved from the URL.

     info = cache.info()

The 'info' returned is an rfc822 Message object for reading rfc822 headers. Note that this object is only useful for reading. If you want to add new headers and have them updated in the cache you will need to call 'add_headers()'.

     cache.add_headers({"md5" : "03030eeeef33, 2034023feef, 23493208903"})

Requirements

Requires Python 2.2 or later

Additional Information

Author
Joe Gregorio
License
MIT
Contributors
Kendall Clark

Download

httpcache.py - The uncompressed source code of the single file that constitutes this module. You can run the file stand-alone to execute the unit tests. Please read the comments in the file for initial setup you will have to do to run the tests successfully.

Revision History

1.0.2
Added the ability to set request headers from Beat Bolli, the author of Plagg.
1.0.1
Added the filename() and fresh() member functions from Kendall Clark.
1.0
Initial Release

This page last updated on: $LastChangedDate: 2006-02-17 10:19:48 -0500 (Fri, 17 Feb 2006) $.