README
1 httplib2 for Python 3
2
3 This directory contains a port of httplib2 to Python 3. As you may
4 know, Python 3 is not backward-compatible with Python 2. The biggest
5 change in Python 3 (that affects httplib2) is the distinction between
6 bytes and strings.
7
8 To successfully use http2lib for Python 3, you absolutely must
9 understand the following sentence:
10
11 ** THE RESPONSE HEADERS ARE STRINGS, BUT THE CONTENT BODY IS BYTES **
12
13
14 Example:
15
16 >>> import httplib2, pprint
17 >>> h = httplib2.Http(".cache")
18 >>> (resp_headers, content) = h.request("http://example.org/", "GET")
19 >>> pprint.pprint(resp_headers)
20 {'accept-ranges': 'bytes',
21 'connection': 'close',
22 'content-length': '438',
23 'content-location': 'http://example.org/',
24 'content-type': 'text/html; charset=UTF-8',
25 'date': 'Fri, 29 May 2009 03:57:29 GMT',
26 'etag': '"b80f4-1b6-80bfd280"',
27 'last-modified': 'Tue, 15 Nov 2005 13:24:10 GMT',
28 'server': 'Apache/2.2.3 (CentOS)',
29 'status': '200'}
30 >>> type(content)
31 <class 'bytes'>
32 >>> content[:49]
33 b'<HTML>\r\n<HEAD>\r\n <TITLE>Example Web Page</TITLE>'
34
35
36 Further reading:
37
38 * http://diveintopython3.org/strings.html
39 * http://docs.python.org/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit
40 * http://docs.python.org/3.0/howto/unicode.html
41
42
43 --------------------------------------------------------------------
44 Httplib2 Software License
45
46 Copyright (c) 2006 by Joe Gregorio
47 Copyright (c) 2009 by Mark Pilgrim
48
49 Permission is hereby granted, free of charge, to any person
50 obtaining a copy of this software and associated documentation
51 files (the "Software"), to deal in the Software without restriction,
52 including without limitation the rights to use, copy, modify, merge,
53 publish, distribute, sublicense, and/or sell copies of the Software,
54 and to permit persons to whom the Software is furnished to do so,
55 subject to the following conditions:
56
57 The above copyright notice and this permission notice shall be
58 included in all copies or substantial portions of the Software.
59
60 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
62 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
64 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
65 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
66 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67 SOFTWARE.
68
69