|
1 |
| -Introduction |
2 |
| -============ |
| 1 | +**Please Note: This repo is deprecated** |
3 | 2 |
|
4 |
| -httplib2 is a comprehensive HTTP client library, httplib2.py supports many |
5 |
| -features left out of other HTTP libraries. |
6 |
| - |
7 |
| -###HTTP and HTTPS |
8 |
| -HTTPS support is only available if the socket module was |
9 |
| -compiled with SSL support. |
10 |
| - |
11 |
| -###Keep-Alive |
12 |
| -Supports HTTP 1.1 Keep-Alive, keeping the socket open and |
13 |
| -performing multiple requests over the same connection if |
14 |
| -possible. |
15 |
| - |
16 |
| -###Authentication |
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 |
| - |
24 |
| -###Caching |
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. |
28 |
| - |
29 |
| -###All Methods |
30 |
| -The module can handle any HTTP request method, not just GET |
31 |
| -and POST. |
32 |
| - |
33 |
| -###Redirects |
34 |
| -Automatically follows 3XX redirects on GETs. |
35 |
| - |
36 |
| -###Compression |
37 |
| -Handles both 'deflate' and 'gzip' types of compression. |
38 |
| - |
39 |
| -###Lost update support |
40 |
| -Automatically adds back ETags into PUT requests to resources |
41 |
| -we have already cached. This implements Section 3.2 of |
42 |
| -Detecting the Lost Update Problem Using Unreserved Checkout. |
43 |
| - |
44 |
| -###Unit Tested |
45 |
| -A large and growing set of unit tests. |
46 |
| - |
47 |
| - |
48 |
| -Installation |
49 |
| -============ |
50 |
| - |
51 |
| - |
52 |
| - $ pip install httplib2 |
53 |
| - |
54 |
| - |
55 |
| -Usage |
56 |
| -===== |
57 |
| - |
58 |
| -A simple retrieval: |
59 |
| - |
60 |
| -```python |
61 |
| -import httplib2 |
62 |
| -h = httplib2.Http(".cache") |
63 |
| -(resp_headers, content) = h.request("http://example.org/", "GET") |
64 |
| -``` |
65 |
| - |
66 |
| -The 'content' is the content retrieved from the URL. The content |
67 |
| -is already decompressed or unzipped if necessary. |
68 |
| - |
69 |
| -To PUT some content to a server that uses SSL and Basic authentication: |
70 |
| - |
71 |
| -```python |
72 |
| -import httplib2 |
73 |
| -h = httplib2.Http(".cache") |
74 |
| -h.add_credentials('name', 'password') |
75 |
| -(resp, content) = h.request("https://example.org/chapter/2", |
76 |
| - "PUT", body="This is text", |
77 |
| - headers={'content-type':'text/plain'} ) |
78 |
| -``` |
79 |
| - |
80 |
| -Use the Cache-Control: header to control how the caching operates. |
81 |
| - |
82 |
| -```python |
83 |
| -import httplib2 |
84 |
| -h = httplib2.Http(".cache") |
85 |
| -(resp, content) = h.request("http://bitworking.org/", "GET") |
86 |
| -... |
87 |
| -(resp, content) = h.request("http://bitworking.org/", "GET", |
88 |
| - headers={'cache-control':'no-cache'}) |
89 |
| -``` |
90 |
| - |
91 |
| -The first request will be cached and since this is a request |
92 |
| -to bitworking.org it will be set to be cached for two hours, |
93 |
| -because that is how I have my server configured. Any subsequent |
94 |
| -GET to that URI will return the value from the on-disk cache |
95 |
| -and no request will be made to the server. You can use the |
96 |
| -Cache-Control: header to change the caches behavior and in |
97 |
| -this example the second request adds the Cache-Control: |
98 |
| -header with a value of 'no-cache' which tells the library |
99 |
| -that the cached copy must not be used when handling this request. |
100 |
| - |
101 |
| -More example usage can be found at: |
102 |
| - |
103 |
| - * https://github.com/jcgregorio/httplib2/wiki/Examples |
104 |
| - * https://github.com/jcgregorio/httplib2/wiki/Examples-Python3 |
| 3 | +Please use the new repo at https://github.com/httplib2. |
0 commit comments