• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..06-Jun-2010-

READMEH A D06-Jun-20104.3 KiB12394

__init__.pyH A D06-Jun-201049.9 KiB1,203916

iri2uri.pyH A D06-Jun-20103.8 KiB11180

README

1Httplib2
2
3--------------------------------------------------------------------
4Introduction
5
6A comprehensive HTTP client library, httplib2.py supports many
7features left out of other HTTP libraries.
8
9HTTP and HTTPS
10    HTTPS support is only available if the socket module was
11    compiled with SSL support.
12Keep-Alive
13    Supports HTTP 1.1 Keep-Alive, keeping the socket open and
14    performing multiple requests over the same connection if
15    possible.
16Authentication
17    The following three types of HTTP Authentication are
18    supported. These can be used over both HTTP and HTTPS.
19
20        * Digest
21        * Basic
22        * WSSE
23
24Caching
25    The module can optionally operate with a private cache that
26    understands the Cache-Control: header and uses both the ETag
27    and Last-Modified cache validators.
28All Methods
29    The module can handle any HTTP request method, not just GET
30    and POST.
31Redirects
32    Automatically follows 3XX redirects on GETs.
33Compression
34    Handles both 'deflate' and 'gzip' types of compression.
35Lost update support
36    Automatically adds back ETags into PUT requests to resources
37    we have already cached. This implements Section 3.2 of
38    Detecting the Lost Update Problem Using Unreserved Checkout.
39Unit Tested
40    A large and growing set of unit tests.
41
42
43For more information on this module, see:
44
45    http://bitworking.org/projects/httplib2/
46
47
48--------------------------------------------------------------------
49Installation
50
51The httplib2 module is shipped as a distutils package.  To install
52the library, unpack the distribution archive, and issue the following
53command:
54
55    $ python setup.py install
56
57
58--------------------------------------------------------------------
59Usage
60A simple retrieval:
61
62  import httplib2
63  h = httplib2.Http(".cache")
64  (resp_headers, content) = h.request("http://example.org/", "GET")
65
66The 'content' is the content retrieved from the URL. The content
67is already decompressed or unzipped if necessary.
68
69To PUT some content to a server that uses SSL and Basic authentication:
70
71  import httplib2
72  h = httplib2.Http(".cache")
73  h.add_credentials('name', 'password')
74  (resp, content) = h.request("https://example.org/chapter/2",
75                            "PUT", body="This is text",
76                            headers={'content-type':'text/plain'} )
77
78Use the Cache-Control: header to control how the caching operates.
79
80  import httplib2
81  h = httplib2.Http(".cache")
82  (resp, content) = h.request("http://bitworking.org/", "GET")
83  ...
84  (resp, content) = h.request("http://bitworking.org/", "GET",
85                            headers={'cache-control':'no-cache'})
86
87The first request will be cached and since this is a request
88to bitworking.org it will be set to be cached for two hours,
89because that is how I have my server configured. Any subsequent
90GET to that URI will return the value from the on-disk cache
91and no request will be made to the server. You can use the
92Cache-Control: header to change the caches behavior and in
93this example the second request adds the Cache-Control:
94header with a value of 'no-cache' which tells the library
95that the cached copy must not be used when handling this request.
96
97
98--------------------------------------------------------------------
99Httplib2 Software License
100
101Copyright (c) 2006 by Joe Gregorio
102
103Permission is hereby granted, free of charge, to any person
104obtaining a copy of this software and associated documentation
105files (the "Software"), to deal in the Software without restriction,
106including without limitation the rights to use, copy, modify, merge,
107publish, distribute, sublicense, and/or sell copies of the Software,
108and to permit persons to whom the Software is furnished to do so,
109subject to the following conditions:
110
111The above copyright notice and this permission notice shall be
112included in all copies or substantial portions of the Software.
113
114THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
115EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
116OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
117NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
118BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
119ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
120CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121SOFTWARE.
122
123