Merge lp:~zulcss/ubuntu/precise/requests/requests-ca into lp:ubuntu/precise/requests

Proposed by Chuck Short
Status: Superseded
Proposed branch: lp:~zulcss/ubuntu/precise/requests/requests-ca
Merge into: lp:ubuntu/precise/requests
Diff against target: 26464 lines (+21254/-3087)
115 files modified
.pc/.quilt_patches (+1/-0)
.pc/.quilt_series (+1/-0)
.pc/.version (+1/-0)
.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/connectionpool.py (+562/-0)
.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/filepost.py (+91/-0)
.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/response.py (+202/-0)
.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/util.py (+252/-0)
.pc/03-use-distro-packages.patch/requests/adapters.py (+58/-0)
.pc/03-use-distro-packages.patch/requests/compat.py (+119/-0)
.pc/03-use-distro-packages.patch/requests/models.py (+907/-0)
.pc/03-use-distro-packages.patch/requests/packages/__init__.py (+3/-0)
.pc/03-use-distro-packages.patch/requests/safe_mode.py (+40/-0)
.pc/03-use-distro-packages.patch/requests/sessions.py (+328/-0)
.pc/03-use-distro-packages.patch/setup.py (+73/-0)
.pc/applied-patches (+2/-0)
HISTORY.rst (+299/-2)
LICENSE (+1/-1)
MANIFEST.in (+1/-1)
NOTICE (+116/-0)
PKG-INFO (+341/-52)
README.rst (+21/-45)
debian/changelog (+137/-0)
debian/control (+38/-23)
debian/copyright (+63/-5)
debian/patches/02_do-not-use-embedded-python-six.patch (+51/-0)
debian/patches/03-use-distro-packages.patch (+127/-0)
debian/patches/series (+2/-0)
debian/rules (+23/-1)
requests.egg-info/PKG-INFO (+341/-52)
requests.egg-info/SOURCES.txt (+61/-6)
requests/__init__.py (+34/-7)
requests/_oauth.py (+23/-0)
requests/adapters.py (+58/-0)
requests/api.py (+33/-46)
requests/async.py (+0/-89)
requests/auth.py (+357/-121)
requests/cacert.pem (+3338/-0)
requests/certs.py (+27/-0)
requests/compat.py (+131/-0)
requests/cookies.py (+377/-0)
requests/defaults.py (+16/-8)
requests/exceptions.py (+26/-3)
requests/hooks.py (+14/-6)
requests/models.py (+512/-240)
requests/packages/__init__.py (+1/-1)
requests/packages/chardet/__init__.py (+26/-0)
requests/packages/chardet/big5freq.py (+923/-0)
requests/packages/chardet/big5prober.py (+41/-0)
requests/packages/chardet/chardistribution.py (+200/-0)
requests/packages/chardet/charsetgroupprober.py (+96/-0)
requests/packages/chardet/charsetprober.py (+60/-0)
requests/packages/chardet/codingstatemachine.py (+56/-0)
requests/packages/chardet/constants.py (+47/-0)
requests/packages/chardet/escprober.py (+79/-0)
requests/packages/chardet/escsm.py (+240/-0)
requests/packages/chardet/eucjpprober.py (+85/-0)
requests/packages/chardet/euckrfreq.py (+594/-0)
requests/packages/chardet/euckrprober.py (+41/-0)
requests/packages/chardet/euctwfreq.py (+426/-0)
requests/packages/chardet/euctwprober.py (+41/-0)
requests/packages/chardet/gb2312freq.py (+471/-0)
requests/packages/chardet/gb2312prober.py (+41/-0)
requests/packages/chardet/hebrewprober.py (+269/-0)
requests/packages/chardet/jisfreq.py (+567/-0)
requests/packages/chardet/jpcntx.py (+210/-0)
requests/packages/chardet/langbulgarianmodel.py (+228/-0)
requests/packages/chardet/langcyrillicmodel.py (+329/-0)
requests/packages/chardet/langgreekmodel.py (+225/-0)
requests/packages/chardet/langhebrewmodel.py (+201/-0)
requests/packages/chardet/langhungarianmodel.py (+225/-0)
requests/packages/chardet/langthaimodel.py (+200/-0)
requests/packages/chardet/latin1prober.py (+136/-0)
requests/packages/chardet/mbcharsetprober.py (+82/-0)
requests/packages/chardet/mbcsgroupprober.py (+50/-0)
requests/packages/chardet/mbcssm.py (+514/-0)
requests/packages/chardet/sbcharsetprober.py (+106/-0)
requests/packages/chardet/sbcsgroupprober.py (+64/-0)
requests/packages/chardet/sjisprober.py (+85/-0)
requests/packages/chardet/universaldetector.py (+154/-0)
requests/packages/chardet/utf8prober.py (+76/-0)
requests/packages/oauthlib/common.py (+229/-0)
requests/packages/oauthlib/oauth1/__init__.py (+13/-0)
requests/packages/oauthlib/oauth1/rfc5849/__init__.py (+889/-0)
requests/packages/oauthlib/oauth1/rfc5849/parameters.py (+134/-0)
requests/packages/oauthlib/oauth1/rfc5849/signature.py (+551/-0)
requests/packages/oauthlib/oauth1/rfc5849/utils.py (+99/-0)
requests/packages/oauthlib/oauth2/__init__.py (+13/-0)
requests/packages/oauthlib/oauth2/draft25/__init__.py (+497/-0)
requests/packages/oauthlib/oauth2/draft25/parameters.py (+256/-0)
requests/packages/oauthlib/oauth2/draft25/tokens.py (+132/-0)
requests/packages/oauthlib/oauth2/draft25/utils.py (+39/-0)
requests/packages/oreos/__init__.py (+0/-3)
requests/packages/oreos/core.py (+0/-24)
requests/packages/oreos/monkeys.py (+0/-770)
requests/packages/oreos/structures.py (+0/-399)
requests/packages/urllib3/__init__.py (+26/-16)
requests/packages/urllib3/_collections.py (+80/-117)
requests/packages/urllib3/connectionpool.py (+187/-150)
requests/packages/urllib3/exceptions.py (+55/-13)
requests/packages/urllib3/filepost.py (+43/-23)
requests/packages/urllib3/packages/__init__.py (+4/-0)
requests/packages/urllib3/packages/ordered_dict.py (+260/-0)
requests/packages/urllib3/packages/six.py (+372/-0)
requests/packages/urllib3/packages/ssl_match_hostname/__init__.py (+61/-0)
requests/packages/urllib3/poolmanager.py (+63/-33)
requests/packages/urllib3/request.py (+6/-23)
requests/packages/urllib3/response.py (+61/-40)
requests/packages/urllib3/util.py (+252/-0)
requests/safe_mode.py (+40/-0)
requests/sessions.py (+109/-60)
requests/status_codes.py (+2/-2)
requests/structures.py (+4/-3)
requests/utils.py (+353/-118)
setup.py (+27/-26)
test_requests.py (+0/-558)
To merge this branch: bzr merge lp:~zulcss/ubuntu/precise/requests/requests-ca
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+145251@code.launchpad.net

This proposal supersedes a proposal from 2013-01-28.

To post a comment you must log in.

Unmerged revisions

19. By Chuck Short

* New upstream release for the Ubuntu Cloud Archvie:
  - Removed python3 version.

18. By Barry Warsaw

* New upstream release (LP: #1076107). Remaining changes:
  - debian/patches/01_do-not-use-python-certifi.patch: No longer necessary.
  - debian/patches/02_do-not-use-embedded-python-six.patch: refreshed
  - debian/patches/03-dont-use-embeded-urllib3.patch: refreshed and
    renamed to 03-use-distro-packages.patch
  - debian/control: python-chardet and python3-chardet are now required
    (i.e. Depends instead of Recommends).

17. By Dave Walker

debian/control: Resolve Depends misspelling of python-urllib3.

16. By Adam Conrad

* Add -r to rm call in debian/rules removing requests/packages/urllib3
* Add python3-urllib3 to build-depends and python3-requests depends

15. By Chuck Short

debian/rules, debian/control,
debian/patches/03-dont-use-embeded-urllib3.patch:
Don't use embeded python-urllib3.

14. By James Page

d/{rules,control}: Disable tests and drop associated deps; 10/11
of them require network connectivity so they break in offline build
environments.

13. By Chuck Short

debian/control: Fix up testsuite some more.

12. By Chuck Short

debia/rules: Enable test suite.

11. By Daniele Tricoli

* New upstream release
* debian/control
  - Added python-oauthlib to python-requests' Recommends field
* debian/patches/01_do-not-use-python-certifi.patch
  - Refreshed

10. By Daniele Tricoli

* New upstream release
* debian/patches/01_do-not-use-python-certifi.patch
  - Refreshed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory '.pc'
=== added file '.pc/.quilt_patches'
--- .pc/.quilt_patches 1970-01-01 00:00:00 +0000
+++ .pc/.quilt_patches 2013-01-28 21:17:21 +0000
@@ -0,0 +1,1 @@
1debian/patches
02
=== added file '.pc/.quilt_series'
--- .pc/.quilt_series 1970-01-01 00:00:00 +0000
+++ .pc/.quilt_series 2013-01-28 21:17:21 +0000
@@ -0,0 +1,1 @@
1series
02
=== added file '.pc/.version'
--- .pc/.version 1970-01-01 00:00:00 +0000
+++ .pc/.version 2013-01-28 21:17:21 +0000
@@ -0,0 +1,1 @@
12
02
=== added directory '.pc/02_do-not-use-embedded-python-six.patch'
=== added directory '.pc/02_do-not-use-embedded-python-six.patch/requests'
=== added directory '.pc/02_do-not-use-embedded-python-six.patch/requests/packages'
=== added directory '.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3'
=== added file '.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/connectionpool.py'
--- .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/connectionpool.py 1970-01-01 00:00:00 +0000
+++ .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/connectionpool.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,562 @@
1# urllib3/connectionpool.py
2# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3#
4# This module is part of urllib3 and is released under
5# the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7import logging
8import socket
9
10from socket import timeout as SocketTimeout
11
12try: # Python 3
13 from http.client import HTTPConnection, HTTPException
14 from http.client import HTTP_PORT, HTTPS_PORT
15except ImportError:
16 from httplib import HTTPConnection, HTTPException
17 from httplib import HTTP_PORT, HTTPS_PORT
18
19try: # Python 3
20 from queue import LifoQueue, Empty, Full
21except ImportError:
22 from Queue import LifoQueue, Empty, Full
23
24
25try: # Compiled with SSL?
26 HTTPSConnection = object
27 BaseSSLError = None
28 ssl = None
29
30 try: # Python 3
31 from http.client import HTTPSConnection
32 except ImportError:
33 from httplib import HTTPSConnection
34
35 import ssl
36 BaseSSLError = ssl.SSLError
37
38except (ImportError, AttributeError): # Platform-specific: No SSL.
39 pass
40
41
42from .request import RequestMethods
43from .response import HTTPResponse
44from .util import get_host, is_connection_dropped
45from .exceptions import (
46 ClosedPoolError,
47 EmptyPoolError,
48 HostChangedError,
49 MaxRetryError,
50 SSLError,
51 TimeoutError,
52)
53
54from .packages.ssl_match_hostname import match_hostname, CertificateError
55from .packages import six
56
57
58xrange = six.moves.xrange
59
60log = logging.getLogger(__name__)
61
62_Default = object()
63
64port_by_scheme = {
65 'http': HTTP_PORT,
66 'https': HTTPS_PORT,
67}
68
69
70## Connection objects (extension of httplib)
71
72class VerifiedHTTPSConnection(HTTPSConnection):
73 """
74 Based on httplib.HTTPSConnection but wraps the socket with
75 SSL certification.
76 """
77 cert_reqs = None
78 ca_certs = None
79
80 def set_cert(self, key_file=None, cert_file=None,
81 cert_reqs='CERT_NONE', ca_certs=None):
82 ssl_req_scheme = {
83 'CERT_NONE': ssl.CERT_NONE,
84 'CERT_OPTIONAL': ssl.CERT_OPTIONAL,
85 'CERT_REQUIRED': ssl.CERT_REQUIRED
86 }
87
88 self.key_file = key_file
89 self.cert_file = cert_file
90 self.cert_reqs = ssl_req_scheme.get(cert_reqs) or ssl.CERT_NONE
91 self.ca_certs = ca_certs
92
93 def connect(self):
94 # Add certificate verification
95 sock = socket.create_connection((self.host, self.port), self.timeout)
96
97 # Wrap socket using verification with the root certs in
98 # trusted_root_certs
99 self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
100 cert_reqs=self.cert_reqs,
101 ca_certs=self.ca_certs)
102 if self.ca_certs:
103 match_hostname(self.sock.getpeercert(), self.host)
104
105
106## Pool objects
107
108class ConnectionPool(object):
109 """
110 Base class for all connection pools, such as
111 :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
112 """
113
114 scheme = None
115 QueueCls = LifoQueue
116
117 def __init__(self, host, port=None):
118 self.host = host
119 self.port = port
120
121 def __str__(self):
122 return '%s(host=%r, port=%r)' % (type(self).__name__,
123 self.host, self.port)
124
125
126class HTTPConnectionPool(ConnectionPool, RequestMethods):
127 """
128 Thread-safe connection pool for one host.
129
130 :param host:
131 Host used for this HTTP Connection (e.g. "localhost"), passed into
132 :class:`httplib.HTTPConnection`.
133
134 :param port:
135 Port used for this HTTP Connection (None is equivalent to 80), passed
136 into :class:`httplib.HTTPConnection`.
137
138 :param strict:
139 Causes BadStatusLine to be raised if the status line can't be parsed
140 as a valid HTTP/1.0 or 1.1 status line, passed into
141 :class:`httplib.HTTPConnection`.
142
143 :param timeout:
144 Socket timeout for each individual connection, can be a float. None
145 disables timeout.
146
147 :param maxsize:
148 Number of connections to save that can be reused. More than 1 is useful
149 in multithreaded situations. If ``block`` is set to false, more
150 connections will be created but they will not be saved once they've
151 been used.
152
153 :param block:
154 If set to True, no more than ``maxsize`` connections will be used at
155 a time. When no free connections are available, the call will block
156 until a connection has been released. This is a useful side effect for
157 particular multithreaded situations where one does not want to use more
158 than maxsize connections per host to prevent flooding.
159
160 :param headers:
161 Headers to include with all requests, unless other headers are given
162 explicitly.
163 """
164
165 scheme = 'http'
166
167 def __init__(self, host, port=None, strict=False, timeout=None, maxsize=1,
168 block=False, headers=None):
169 super(HTTPConnectionPool, self).__init__(host, port)
170
171 self.strict = strict
172 self.timeout = timeout
173 self.pool = self.QueueCls(maxsize)
174 self.block = block
175 self.headers = headers or {}
176
177 # Fill the queue up so that doing get() on it will block properly
178 for _ in xrange(maxsize):
179 self.pool.put(None)
180
181 # These are mostly for testing and debugging purposes.
182 self.num_connections = 0
183 self.num_requests = 0
184
185 def _new_conn(self):
186 """
187 Return a fresh :class:`httplib.HTTPConnection`.
188 """
189 self.num_connections += 1
190 log.info("Starting new HTTP connection (%d): %s" %
191 (self.num_connections, self.host))
192 return HTTPConnection(host=self.host, port=self.port)
193
194 def _get_conn(self, timeout=None):
195 """
196 Get a connection. Will return a pooled connection if one is available.
197
198 If no connections are available and :prop:`.block` is ``False``, then a
199 fresh connection is returned.
200
201 :param timeout:
202 Seconds to wait before giving up and raising
203 :class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
204 :prop:`.block` is ``True``.
205 """
206 conn = None
207 try:
208 conn = self.pool.get(block=self.block, timeout=timeout)
209
210 except AttributeError: # self.pool is None
211 raise ClosedPoolError(self, "Pool is closed.")
212
213 except Empty:
214 if self.block:
215 raise EmptyPoolError(self,
216 "Pool reached maximum size and no more "
217 "connections are allowed.")
218 pass # Oh well, we'll create a new connection then
219
220 # If this is a persistent connection, check if it got disconnected
221 if conn and is_connection_dropped(conn):
222 log.info("Resetting dropped connection: %s" % self.host)
223 conn.close()
224
225 return conn or self._new_conn()
226
227 def _put_conn(self, conn):
228 """
229 Put a connection back into the pool.
230
231 :param conn:
232 Connection object for the current host and port as returned by
233 :meth:`._new_conn` or :meth:`._get_conn`.
234
235 If the pool is already full, the connection is closed and discarded
236 because we exceeded maxsize. If connections are discarded frequently,
237 then maxsize should be increased.
238
239 If the pool is closed, then the connection will be closed and discarded.
240 """
241 try:
242 self.pool.put(conn, block=False)
243 return # Everything is dandy, done.
244 except AttributeError:
245 # self.pool is None.
246 pass
247 except Full:
248 # This should never happen if self.block == True
249 log.warning("HttpConnectionPool is full, discarding connection: %s"
250 % self.host)
251
252 # Connection never got put back into the pool, close it.
253 conn.close()
254
255 def _make_request(self, conn, method, url, timeout=_Default,
256 **httplib_request_kw):
257 """
258 Perform a request on a given httplib connection object taken from our
259 pool.
260 """
261 self.num_requests += 1
262
263 if timeout is _Default:
264 timeout = self.timeout
265
266 conn.timeout = timeout # This only does anything in Py26+
267 conn.request(method, url, **httplib_request_kw)
268
269 # Set timeout
270 sock = getattr(conn, 'sock', False) # AppEngine doesn't have sock attr.
271 if sock:
272 sock.settimeout(timeout)
273
274 try: # Python 2.7+, use buffering of HTTP responses
275 httplib_response = conn.getresponse(buffering=True)
276 except TypeError: # Python 2.6 and older
277 httplib_response = conn.getresponse()
278
279 # AppEngine doesn't have a version attr.
280 http_version = getattr(conn, '_http_vsn_str', 'HTTP/?')
281 log.debug("\"%s %s %s\" %s %s" % (method, url, http_version,
282 httplib_response.status,
283 httplib_response.length))
284 return httplib_response
285
286 def close(self):
287 """
288 Close all pooled connections and disable the pool.
289 """
290 # Disable access to the pool
291 old_pool, self.pool = self.pool, None
292
293 try:
294 while True:
295 conn = old_pool.get(block=False)
296 if conn:
297 conn.close()
298
299 except Empty:
300 pass # Done.
301
302 def is_same_host(self, url):
303 """
304 Check if the given ``url`` is a member of the same host as this
305 connection pool.
306 """
307 if url.startswith('/'):
308 return True
309
310 # TODO: Add optional support for socket.gethostbyname checking.
311 scheme, host, port = get_host(url)
312
313 if self.port and not port:
314 # Use explicit default port for comparison when none is given.
315 port = port_by_scheme.get(scheme)
316
317 return (scheme, host, port) == (self.scheme, self.host, self.port)
318
319 def urlopen(self, method, url, body=None, headers=None, retries=3,
320 redirect=True, assert_same_host=True, timeout=_Default,
321 pool_timeout=None, release_conn=None, **response_kw):
322 """
323 Get a connection from the pool and perform an HTTP request. This is the
324 lowest level call for making a request, so you'll need to specify all
325 the raw details.
326
327 .. note::
328
329 More commonly, it's appropriate to use a convenience method provided
330 by :class:`.RequestMethods`, such as :meth:`request`.
331
332 .. note::
333
334 `release_conn` will only behave as expected if
335 `preload_content=False` because we want to make
336 `preload_content=False` the default behaviour someday soon without
337 breaking backwards compatibility.
338
339 :param method:
340 HTTP request method (such as GET, POST, PUT, etc.)
341
342 :param body:
343 Data to send in the request body (useful for creating
344 POST requests, see HTTPConnectionPool.post_url for
345 more convenience).
346
347 :param headers:
348 Dictionary of custom headers to send, such as User-Agent,
349 If-None-Match, etc. If None, pool headers are used. If provided,
350 these headers completely replace any pool-specific headers.
351
352 :param retries:
353 Number of retries to allow before raising a MaxRetryError exception.
354
355 :param redirect:
356 If True, automatically handle redirects (status codes 301, 302,
357 303, 307). Each redirect counts as a retry.
358
359 :param assert_same_host:
360 If ``True``, will make sure that the host of the pool requests is
361 consistent else will raise HostChangedError. When False, you can
362 use the pool on an HTTP proxy and request foreign hosts.
363
364 :param timeout:
365 If specified, overrides the default timeout for this one request.
366
367 :param pool_timeout:
368 If set and the pool is set to block=True, then this method will
369 block for ``pool_timeout`` seconds and raise EmptyPoolError if no
370 connection is available within the time period.
371
372 :param release_conn:
373 If False, then the urlopen call will not release the connection
374 back into the pool once a response is received (but will release if
375 you read the entire contents of the response such as when
376 `preload_content=True`). This is useful if you're not preloading
377 the response's content immediately. You will need to call
378 ``r.release_conn()`` on the response ``r`` to return the connection
379 back into the pool. If None, it takes the value of
380 ``response_kw.get('preload_content', True)``.
381
382 :param \**response_kw:
383 Additional parameters are passed to
384 :meth:`urllib3.response.HTTPResponse.from_httplib`
385 """
386 if headers is None:
387 headers = self.headers
388
389 if retries < 0:
390 raise MaxRetryError(self, url)
391
392 if timeout is _Default:
393 timeout = self.timeout
394
395 if release_conn is None:
396 release_conn = response_kw.get('preload_content', True)
397
398 # Check host
399 if assert_same_host and not self.is_same_host(url):
400 host = "%s://%s" % (self.scheme, self.host)
401 if self.port:
402 host = "%s:%d" % (host, self.port)
403
404 raise HostChangedError(self, url, retries - 1)
405
406 conn = None
407
408 try:
409 # Request a connection from the queue
410 conn = self._get_conn(timeout=pool_timeout)
411
412 # Make the request on the httplib connection object
413 httplib_response = self._make_request(conn, method, url,
414 timeout=timeout,
415 body=body, headers=headers)
416
417 # If we're going to release the connection in ``finally:``, then
418 # the request doesn't need to know about the connection. Otherwise
419 # it will also try to release it and we'll have a double-release
420 # mess.
421 response_conn = not release_conn and conn
422
423 # Import httplib's response into our own wrapper object
424 response = HTTPResponse.from_httplib(httplib_response,
425 pool=self,
426 connection=response_conn,
427 **response_kw)
428
429 # else:
430 # The connection will be put back into the pool when
431 # ``response.release_conn()`` is called (implicitly by
432 # ``response.read()``)
433
434 except Empty as e:
435 # Timed out by queue
436 raise TimeoutError(self, "Request timed out. (pool_timeout=%s)" %
437 pool_timeout)
438
439 except SocketTimeout as e:
440 # Timed out by socket
441 raise TimeoutError(self, "Request timed out. (timeout=%s)" %
442 timeout)
443
444 except BaseSSLError as e:
445 # SSL certificate error
446 raise SSLError(e)
447
448 except CertificateError as e:
449 # Name mismatch
450 raise SSLError(e)
451
452 except HTTPException as e:
453 # Connection broken, discard. It will be replaced next _get_conn().
454 conn = None
455 # This is necessary so we can access e below
456 err = e
457
458 finally:
459 if release_conn:
460 # Put the connection back to be reused. If the connection is
461 # expired then it will be None, which will get replaced with a
462 # fresh connection during _get_conn.
463 self._put_conn(conn)
464
465 if not conn:
466 # Try again
467 log.warn("Retrying (%d attempts remain) after connection "
468 "broken by '%r': %s" % (retries, err, url))
469 return self.urlopen(method, url, body, headers, retries - 1,
470 redirect, assert_same_host,
471 timeout=timeout, pool_timeout=pool_timeout,
472 release_conn=release_conn, **response_kw)
473
474 # Handle redirect?
475 redirect_location = redirect and response.get_redirect_location()
476 if redirect_location:
477 if response.status == 303:
478 method = 'GET'
479 log.info("Redirecting %s -> %s" % (url, redirect_location))
480 return self.urlopen(method, redirect_location, body, headers,
481 retries - 1, redirect, assert_same_host,
482 timeout=timeout, pool_timeout=pool_timeout,
483 release_conn=release_conn, **response_kw)
484
485 return response
486
487
488class HTTPSConnectionPool(HTTPConnectionPool):
489 """
490 Same as :class:`.HTTPConnectionPool`, but HTTPS.
491
492 When Python is compiled with the :mod:`ssl` module, then
493 :class:`.VerifiedHTTPSConnection` is used, which *can* verify certificates,
494 instead of :class:httplib.HTTPSConnection`.
495
496 The ``key_file``, ``cert_file``, ``cert_reqs``, and ``ca_certs`` parameters
497 are only used if :mod:`ssl` is available and are fed into
498 :meth:`ssl.wrap_socket` to upgrade the connection socket into an SSL socket.
499 """
500
501 scheme = 'https'
502
503 def __init__(self, host, port=None,
504 strict=False, timeout=None, maxsize=1,
505 block=False, headers=None,
506 key_file=None, cert_file=None,
507 cert_reqs='CERT_NONE', ca_certs=None):
508
509 super(HTTPSConnectionPool, self).__init__(host, port,
510 strict, timeout, maxsize,
511 block, headers)
512 self.key_file = key_file
513 self.cert_file = cert_file
514 self.cert_reqs = cert_reqs
515 self.ca_certs = ca_certs
516
517 def _new_conn(self):
518 """
519 Return a fresh :class:`httplib.HTTPSConnection`.
520 """
521 self.num_connections += 1
522 log.info("Starting new HTTPS connection (%d): %s"
523 % (self.num_connections, self.host))
524
525 if not ssl: # Platform-specific: Python compiled without +ssl
526 if not HTTPSConnection or HTTPSConnection is object:
527 raise SSLError("Can't connect to HTTPS URL because the SSL "
528 "module is not available.")
529
530 return HTTPSConnection(host=self.host, port=self.port)
531
532 connection = VerifiedHTTPSConnection(host=self.host, port=self.port)
533 connection.set_cert(key_file=self.key_file, cert_file=self.cert_file,
534 cert_reqs=self.cert_reqs, ca_certs=self.ca_certs)
535 return connection
536
537
538def connection_from_url(url, **kw):
539 """
540 Given a url, return an :class:`.ConnectionPool` instance of its host.
541
542 This is a shortcut for not having to parse out the scheme, host, and port
543 of the url before creating an :class:`.ConnectionPool` instance.
544
545 :param url:
546 Absolute URL string that must include the scheme. Port is optional.
547
548 :param \**kw:
549 Passes additional parameters to the constructor of the appropriate
550 :class:`.ConnectionPool`. Useful for specifying things like
551 timeout, maxsize, headers, etc.
552
553 Example: ::
554
555 >>> conn = connection_from_url('http://google.com/')
556 >>> r = conn.request('GET', '/')
557 """
558 scheme, host, port = get_host(url)
559 if scheme == 'https':
560 return HTTPSConnectionPool(host, port=port, **kw)
561 else:
562 return HTTPConnectionPool(host, port=port, **kw)
0563
=== added file '.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/filepost.py'
--- .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/filepost.py 1970-01-01 00:00:00 +0000
+++ .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/filepost.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,91 @@
1# urllib3/filepost.py
2# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3#
4# This module is part of urllib3 and is released under
5# the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7import codecs
8import mimetypes
9
10from uuid import uuid4
11from io import BytesIO
12
13from .packages import six
14from .packages.six import b
15
16writer = codecs.lookup('utf-8')[3]
17
18
19def choose_boundary():
20 """
21 Our embarassingly-simple replacement for mimetools.choose_boundary.
22 """
23 return uuid4().hex
24
25
26def get_content_type(filename):
27 return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
28
29
30def iter_fields(fields):
31 """
32 Iterate over fields.
33
34 Supports list of (k, v) tuples and dicts.
35 """
36 if isinstance(fields, dict):
37 return ((k, v) for k, v in six.iteritems(fields))
38
39 return ((k, v) for k, v in fields)
40
41
42def encode_multipart_formdata(fields, boundary=None):
43 """
44 Encode a dictionary of ``fields`` using the multipart/form-data mime format.
45
46 :param fields:
47 Dictionary of fields or list of (key, value) field tuples. The key is
48 treated as the field name, and the value as the body of the form-data
49 bytes. If the value is a tuple of two elements, then the first element
50 is treated as the filename of the form-data section.
51
52 Field names and filenames must be unicode.
53
54 :param boundary:
55 If not specified, then a random boundary will be generated using
56 :func:`mimetools.choose_boundary`.
57 """
58 body = BytesIO()
59 if boundary is None:
60 boundary = choose_boundary()
61
62 for fieldname, value in iter_fields(fields):
63 body.write(b('--%s\r\n' % (boundary)))
64
65 if isinstance(value, tuple):
66 filename, data = value
67 writer(body).write('Content-Disposition: form-data; name="%s"; '
68 'filename="%s"\r\n' % (fieldname, filename))
69 body.write(b('Content-Type: %s\r\n\r\n' %
70 (get_content_type(filename))))
71 else:
72 data = value
73 writer(body).write('Content-Disposition: form-data; name="%s"\r\n'
74 % (fieldname))
75 body.write(b'Content-Type: text/plain\r\n\r\n')
76
77 if isinstance(data, int):
78 data = str(data) # Backwards compatibility
79
80 if isinstance(data, six.text_type):
81 writer(body).write(data)
82 else:
83 body.write(data)
84
85 body.write(b'\r\n')
86
87 body.write(b('--%s--\r\n' % (boundary)))
88
89 content_type = b('multipart/form-data; boundary=%s' % boundary)
90
91 return body.getvalue(), content_type
092
=== added file '.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/response.py'
--- .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/response.py 1970-01-01 00:00:00 +0000
+++ .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/response.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,202 @@
1# urllib3/response.py
2# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3#
4# This module is part of urllib3 and is released under
5# the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7import gzip
8import logging
9import zlib
10
11from io import BytesIO
12
13from .exceptions import DecodeError
14from .packages.six import string_types as basestring
15
16
17log = logging.getLogger(__name__)
18
19
20def decode_gzip(data):
21 gzipper = gzip.GzipFile(fileobj=BytesIO(data))
22 return gzipper.read()
23
24
25def decode_deflate(data):
26 try:
27 return zlib.decompress(data)
28 except zlib.error:
29 return zlib.decompress(data, -zlib.MAX_WBITS)
30
31
32class HTTPResponse(object):
33 """
34 HTTP Response container.
35
36 Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
37 loaded and decoded on-demand when the ``data`` property is accessed.
38
39 Extra parameters for behaviour not present in httplib.HTTPResponse:
40
41 :param preload_content:
42 If True, the response's body will be preloaded during construction.
43
44 :param decode_content:
45 If True, attempts to decode specific content-encoding's based on headers
46 (like 'gzip' and 'deflate') will be skipped and raw data will be used
47 instead.
48
49 :param original_response:
50 When this HTTPResponse wrapper is generated from an httplib.HTTPResponse
51 object, it's convenient to include the original for debug purposes. It's
52 otherwise unused.
53 """
54
55 CONTENT_DECODERS = {
56 'gzip': decode_gzip,
57 'deflate': decode_deflate,
58 }
59
60 def __init__(self, body='', headers=None, status=0, version=0, reason=None,
61 strict=0, preload_content=True, decode_content=True,
62 original_response=None, pool=None, connection=None):
63 self.headers = headers or {}
64 self.status = status
65 self.version = version
66 self.reason = reason
67 self.strict = strict
68
69 self._decode_content = decode_content
70 self._body = body if body and isinstance(body, basestring) else None
71 self._fp = None
72 self._original_response = original_response
73
74 self._pool = pool
75 self._connection = connection
76
77 if hasattr(body, 'read'):
78 self._fp = body
79
80 if preload_content and not self._body:
81 self._body = self.read(decode_content=decode_content)
82
83 def get_redirect_location(self):
84 """
85 Should we redirect and where to?
86
87 :returns: Truthy redirect location string if we got a redirect status
88 code and valid location. ``None`` if redirect status and no
89 location. ``False`` if not a redirect status code.
90 """
91 if self.status in [301, 302, 303, 307]:
92 return self.headers.get('location')
93
94 return False
95
96 def release_conn(self):
97 if not self._pool or not self._connection:
98 return
99
100 self._pool._put_conn(self._connection)
101 self._connection = None
102
103 @property
104 def data(self):
105 # For backwords-compat with earlier urllib3 0.4 and earlier.
106 if self._body:
107 return self._body
108
109 if self._fp:
110 return self.read(cache_content=True)
111
112 def read(self, amt=None, decode_content=None, cache_content=False):
113 """
114 Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
115 parameters: ``decode_content`` and ``cache_content``.
116
117 :param amt:
118 How much of the content to read. If specified, decoding and caching
119 is skipped because we can't decode partial content nor does it make
120 sense to cache partial content as the full response.
121
122 :param decode_content:
123 If True, will attempt to decode the body based on the
124 'content-encoding' header. (Overridden if ``amt`` is set.)
125
126 :param cache_content:
127 If True, will save the returned data such that the same result is
128 returned despite of the state of the underlying file object. This
129 is useful if you want the ``.data`` property to continue working
130 after having ``.read()`` the file object. (Overridden if ``amt`` is
131 set.)
132 """
133 content_encoding = self.headers.get('content-encoding')
134 decoder = self.CONTENT_DECODERS.get(content_encoding)
135 if decode_content is None:
136 decode_content = self._decode_content
137
138 if self._fp is None:
139 return
140
141 try:
142 if amt is None:
143 # cStringIO doesn't like amt=None
144 data = self._fp.read()
145 else:
146 return self._fp.read(amt)
147
148 try:
149 if decode_content and decoder:
150 data = decoder(data)
151 except (IOError, zlib.error):
152 raise DecodeError("Received response with content-encoding: %s, but "
153 "failed to decode it." % content_encoding)
154
155 if cache_content:
156 self._body = data
157
158 return data
159
160 finally:
161 if self._original_response and self._original_response.isclosed():
162 self.release_conn()
163
164 @classmethod
165 def from_httplib(ResponseCls, r, **response_kw):
166 """
167 Given an :class:`httplib.HTTPResponse` instance ``r``, return a
168 corresponding :class:`urllib3.response.HTTPResponse` object.
169
170 Remaining parameters are passed to the HTTPResponse constructor, along
171 with ``original_response=r``.
172 """
173
174 # Normalize headers between different versions of Python
175 headers = {}
176 for k, v in r.getheaders():
177 # Python 3: Header keys are returned capitalised
178 k = k.lower()
179
180 has_value = headers.get(k)
181 if has_value: # Python 3: Repeating header keys are unmerged.
182 v = ', '.join([has_value, v])
183
184 headers[k] = v
185
186 # HTTPResponse objects in Python 3 don't have a .strict attribute
187 strict = getattr(r, 'strict', 0)
188 return ResponseCls(body=r,
189 headers=headers,
190 status=r.status,
191 version=r.version,
192 reason=r.reason,
193 strict=strict,
194 original_response=r,
195 **response_kw)
196
197 # Backwards-compatibility methods for httplib.HTTPResponse
198 def getheaders(self):
199 return self.headers
200
201 def getheader(self, name, default=None):
202 return self.headers.get(name, default)
0203
=== added file '.pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/util.py'
--- .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/util.py 1970-01-01 00:00:00 +0000
+++ .pc/02_do-not-use-embedded-python-six.patch/requests/packages/urllib3/util.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,252 @@
1# urllib3/util.py
2# Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
3#
4# This module is part of urllib3 and is released under
5# the MIT License: http://www.opensource.org/licenses/mit-license.php
6
7
8from base64 import b64encode
9from collections import namedtuple
10from socket import error as SocketError
11
12try:
13 from select import poll, POLLIN
14except ImportError: # `poll` doesn't exist on OSX and other platforms
15 poll = False
16 try:
17 from select import select
18 except ImportError: # `select` doesn't exist on AppEngine.
19 select = False
20
21from .packages import six
22from .exceptions import LocationParseError
23
24
25class Url(namedtuple('Url', ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment'])):
26 """
27 Datastructure for representing an HTTP URL. Used as a return value for
28 :func:`parse_url`.
29 """
30 slots = ()
31
32 def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None, query=None, fragment=None):
33 return super(Url, cls).__new__(cls, scheme, auth, host, port, path, query, fragment)
34
35 @property
36 def hostname(self):
37 """For backwards-compatibility with urlparse. We're nice like that."""
38 return self.host
39
40 @property
41 def request_uri(self):
42 """Absolute path including the query string."""
43 uri = self.path or '/'
44
45 if self.query is not None:
46 uri += '?' + self.query
47
48 return uri
49
50
51def split_first(s, delims):
52 """
53 Given a string and an iterable of delimiters, split on the first found
54 delimiter. Return two split parts and the matched delimiter.
55
56 If not found, then the first part is the full input string.
57
58 Example: ::
59
60 >>> split_first('foo/bar?baz', '?/=')
61 ('foo', 'bar?baz', '/')
62 >>> split_first('foo/bar?baz', '123')
63 ('foo/bar?baz', '', None)
64
65 Scales linearly with number of delims. Not ideal for large number of delims.
66 """
67 min_idx = None
68 min_delim = None
69 for d in delims:
70 idx = s.find(d)
71 if idx < 0:
72 continue
73
74 if min_idx is None or idx < min_idx:
75 min_idx = idx
76 min_delim = d
77
78 if min_idx is None or min_idx < 0:
79 return s, '', None
80
81 return s[:min_idx], s[min_idx+1:], min_delim
82
83
84def parse_url(url):
85 """
86 Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
87 performed to parse incomplete urls. Fields not provided will be None.
88
89 Partly backwards-compatible with :mod:`urlparse`.
90
91 Example: ::
92
93 >>> parse_url('http://google.com/mail/')
94 Url(scheme='http', host='google.com', port=None, path='/', ...)
95 >>> prase_url('google.com:80')
96 Url(scheme=None, host='google.com', port=80, path=None, ...)
97 >>> prase_url('/foo?bar')
98 Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
99 """
100
101 # While this code has overlap with stdlib's urlparse, it is much
102 # simplified for our needs and less annoying.
103 # Additionally, this imeplementations does silly things to be optimal
104 # on CPython.
105
106 scheme = None
107 auth = None
108 host = None
109 port = None
110 path = None
111 fragment = None
112 query = None
113
114 # Scheme
115 if '://' in url:
116 scheme, url = url.split('://', 1)
117
118 # Find the earliest Authority Terminator
119 # (http://tools.ietf.org/html/rfc3986#section-3.2)
120 url, path_, delim = split_first(url, ['/', '?', '#'])
121
122 if delim:
123 # Reassemble the path
124 path = delim + path_
125
126 # Auth
127 if '@' in url:
128 auth, url = url.split('@', 1)
129
130 # IPv6
131 if url and url[0] == '[':
132 host, url = url[1:].split(']', 1)
133
134 # Port
135 if ':' in url:
136 _host, port = url.split(':', 1)
137
138 if not host:
139 host = _host
140
141 if not port.isdigit():
142 raise LocationParseError("Failed to parse: %s" % url)
143
144 port = int(port)
145
146 elif not host and url:
147 host = url
148
149 if not path:
150 return Url(scheme, auth, host, port, path, query, fragment)
151
152 # Fragment
153 if '#' in path:
154 path, fragment = path.split('#', 1)
155
156 # Query
157 if '?' in path:
158 path, query = path.split('?', 1)
159
160 return Url(scheme, auth, host, port, path, query, fragment)
161
162
163def get_host(url):
164 """
165 Deprecated. Use :func:`.parse_url` instead.
166 """
167 p = parse_url(url)
168 return p.scheme or 'http', p.hostname, p.port
169
170
171def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,
172 basic_auth=None):
173 """
174 Shortcuts for generating request headers.
175
176 :param keep_alive:
177 If ``True``, adds 'connection: keep-alive' header.
178
179 :param accept_encoding:
180 Can be a boolean, list, or string.
181 ``True`` translates to 'gzip,deflate'.
182 List will get joined by comma.
183 String will be used as provided.
184
185 :param user_agent:
186 String representing the user-agent you want, such as
187 "python-urllib3/0.6"
188
189 :param basic_auth:
190 Colon-separated username:password string for 'authorization: basic ...'
191 auth header.
192
193 Example: ::
194
195 >>> make_headers(keep_alive=True, user_agent="Batman/1.0")
196 {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
197 >>> make_headers(accept_encoding=True)
198 {'accept-encoding': 'gzip,deflate'}
199 """
200 headers = {}
201 if accept_encoding:
202 if isinstance(accept_encoding, str):
203 pass
204 elif isinstance(accept_encoding, list):
205 accept_encoding = ','.join(accept_encoding)
206 else:
207 accept_encoding = 'gzip,deflate'
208 headers['accept-encoding'] = accept_encoding
209
210 if user_agent:
211 headers['user-agent'] = user_agent
212
213 if keep_alive:
214 headers['connection'] = 'keep-alive'
215
216 if basic_auth:
217 headers['authorization'] = 'Basic ' + \
218 b64encode(six.b(basic_auth)).decode('utf-8')
219
220 return headers
221
222
223def is_connection_dropped(conn):
224 """
225 Returns True if the connection is dropped and should be closed.
226
227 :param conn:
228 :class:`httplib.HTTPConnection` object.
229
230 Note: For platforms like AppEngine, this will always return ``False`` to
231 let the platform handle connection recycling transparently for us.
232 """
233 sock = getattr(conn, 'sock', False)
234 if not sock: # Platform-specific: AppEngine
235 return False
236
237 if not poll: # Platform-specific
238 if not select: # Platform-specific: AppEngine
239 return False
240
241 try:
242 return select([sock], [], [], 0.0)[0]
243 except SocketError:
244 return True
245
246 # This version is better on platforms that support it.
247 p = poll()
248 p.register(sock, POLLIN)
249 for (fno, ev) in p.poll(0.0):
250 if fno == sock.fileno():
251 # Either data is buffered (bad), or the connection is dropped.
252 return True
0253
=== added directory '.pc/03-use-distro-packages.patch'
=== added directory '.pc/03-use-distro-packages.patch/requests'
=== added file '.pc/03-use-distro-packages.patch/requests/adapters.py'
--- .pc/03-use-distro-packages.patch/requests/adapters.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/adapters.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,58 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests.adapters
5~~~~~~~~~~~~~~~~~
6
7This module contains the transport adapters that Requests uses to define
8and maintain connections.
9"""
10
11from .packages.urllib3.poolmanager import PoolManager
12
13class BaseAdapter(object):
14 """The Base Transport Adapter"""
15
16 def __init__(self, config=None):
17 super(BaseAdapter, self).__init__()
18 self.config = config or {}
19 self.session = None
20
21 @property
22 def configure(self, config):
23 self.config.update(config)
24
25 def send(self):
26 raise NotImplementedError
27
28 def close(self):
29 raise NotImplementedError
30
31
32class HTTPAdapter(BaseAdapter):
33 """Built-In HTTP Adapter for Urllib3."""
34 def __init__(self):
35 super(HTTPAdapter, self).__init__()
36
37 self.init_poolmanager()
38
39 def init_poolmanager(self):
40 self.poolmanager = PoolManager(
41 num_pools=self.config.get('pool_connections'),
42 maxsize=self.config.get('pool_maxsize')
43 )
44
45 def close(self):
46 """Dispose of any internal state.
47
48 Currently, this just closes the PoolManager, which closes pooled
49 connections.
50 """
51 self.poolmanager.clear()
52
53 def send(self, request):
54 """Sends request object. Returns Response object."""
55 pass
56
57
58
059
=== added file '.pc/03-use-distro-packages.patch/requests/compat.py'
--- .pc/03-use-distro-packages.patch/requests/compat.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/compat.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,119 @@
1# -*- coding: utf-8 -*-
2
3"""
4pythoncompat
5"""
6
7
8import sys
9
10# -------
11# Pythons
12# -------
13
14# Syntax sugar.
15_ver = sys.version_info
16
17#: Python 2.x?
18is_py2 = (_ver[0] == 2)
19
20#: Python 3.x?
21is_py3 = (_ver[0] == 3)
22
23#: Python 3.0.x
24is_py30 = (is_py3 and _ver[1] == 0)
25
26#: Python 3.1.x
27is_py31 = (is_py3 and _ver[1] == 1)
28
29#: Python 3.2.x
30is_py32 = (is_py3 and _ver[1] == 2)
31
32#: Python 3.3.x
33is_py33 = (is_py3 and _ver[1] == 3)
34
35#: Python 3.4.x
36is_py34 = (is_py3 and _ver[1] == 4)
37
38#: Python 2.7.x
39is_py27 = (is_py2 and _ver[1] == 7)
40
41#: Python 2.6.x
42is_py26 = (is_py2 and _ver[1] == 6)
43
44#: Python 2.5.x
45is_py25 = (is_py2 and _ver[1] == 5)
46
47#: Python 2.4.x
48is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.
49
50
51# ---------
52# Platforms
53# ---------
54
55
56# Syntax sugar.
57_ver = sys.version.lower()
58
59is_pypy = ('pypy' in _ver)
60is_jython = ('jython' in _ver)
61is_ironpython = ('iron' in _ver)
62
63# Assume CPython, if nothing else.
64is_cpython = not any((is_pypy, is_jython, is_ironpython))
65
66# Windows-based system.
67is_windows = 'win32' in str(sys.platform).lower()
68
69# Standard Linux 2+ system.
70is_linux = ('linux' in str(sys.platform).lower())
71is_osx = ('darwin' in str(sys.platform).lower())
72is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
73is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.
74
75try:
76 import simplejson as json
77except ImportError:
78 import json
79
80# ---------
81# Specifics
82# ---------
83
84
85if is_py2:
86 from urllib import quote, unquote, quote_plus, unquote_plus, urlencode
87 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
88 from urllib2 import parse_http_list
89 import cookielib
90 from Cookie import Morsel
91 from StringIO import StringIO
92 try:
93 import cchardet as chardet
94 except ImportError:
95 from .packages import chardet
96 from .packages.urllib3.packages.ordered_dict import OrderedDict
97
98 builtin_str = str
99 bytes = str
100 str = unicode
101 basestring = basestring
102 numeric_types = (int, long, float)
103
104
105
106elif is_py3:
107 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
108 from urllib.request import parse_http_list
109 from http import cookiejar as cookielib
110 from http.cookies import Morsel
111 from io import StringIO
112 from .packages import chardet2 as chardet
113 from collections import OrderedDict
114
115 builtin_str = str
116 str = str
117 bytes = bytes
118 basestring = (str, bytes)
119 numeric_types = (int, float)
0120
=== added file '.pc/03-use-distro-packages.patch/requests/models.py'
--- .pc/03-use-distro-packages.patch/requests/models.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/models.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,907 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests.models
5~~~~~~~~~~~~~~~
6
7This module contains the primary objects that power Requests.
8"""
9
10import os
11import socket
12from datetime import datetime
13from io import BytesIO
14
15from .hooks import dispatch_hook, HOOKS
16from .structures import CaseInsensitiveDict
17from .status_codes import codes
18
19from .auth import HTTPBasicAuth, HTTPProxyAuth
20from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header
21from .packages.urllib3.exceptions import MaxRetryError, LocationParseError
22from .packages.urllib3.exceptions import TimeoutError
23from .packages.urllib3.exceptions import SSLError as _SSLError
24from .packages.urllib3.exceptions import HTTPError as _HTTPError
25from .packages.urllib3 import connectionpool, poolmanager
26from .packages.urllib3.filepost import encode_multipart_formdata
27from .defaults import SCHEMAS
28from .exceptions import (
29 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,
30 URLRequired, SSLError, MissingSchema, InvalidSchema, InvalidURL)
31from .utils import (
32 get_encoding_from_headers, stream_untransfer, guess_filename, requote_uri,
33 stream_decode_response_unicode, get_netrc_auth, get_environ_proxies,
34 to_key_val_list, DEFAULT_CA_BUNDLE_PATH, parse_header_links, iter_slices,
35 guess_json_utf)
36from .compat import (
37 cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,
38 StringIO, is_py2, chardet, json, builtin_str, urldefrag)
39
40REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)
41CONTENT_CHUNK_SIZE = 10 * 1024
42
43
44class Request(object):
45 """The :class:`Request <Request>` object. It carries out all functionality
46 of Requests. Recommended interface is with the Requests functions.
47 """
48
49 def __init__(self,
50 url=None,
51 headers=dict(),
52 files=None,
53 method=None,
54 data=dict(),
55 params=dict(),
56 auth=None,
57 cookies=None,
58 timeout=None,
59 redirect=False,
60 allow_redirects=False,
61 proxies=None,
62 hooks=None,
63 config=None,
64 prefetch=True,
65 _poolmanager=None,
66 verify=None,
67 session=None,
68 cert=None):
69
70 #: Dictionary of configurations for this request.
71 self.config = dict(config or [])
72
73 #: Float describes the timeout of the request.
74 # (Use socket.setdefaulttimeout() as fallback)
75 self.timeout = timeout
76
77 #: Request URL.
78 #: Accept objects that have string representations.
79 try:
80 self.url = unicode(url)
81 except NameError:
82 # We're on Python 3.
83 self.url = str(url)
84 except UnicodeDecodeError:
85 self.url = url
86
87 #: Dictionary of HTTP Headers to attach to the :class:`Request <Request>`.
88 self.headers = dict(headers or [])
89
90 #: Dictionary of files to multipart upload (``{filename: content}``).
91 self.files = None
92
93 #: HTTP Method to use.
94 self.method = method
95
96 #: Dictionary, bytes or file stream of request body data to attach to the
97 #: :class:`Request <Request>`.
98 self.data = None
99
100 #: Dictionary or byte of querystring data to attach to the
101 #: :class:`Request <Request>`. The dictionary values can be lists for representing
102 #: multivalued query parameters.
103 self.params = None
104
105 #: True if :class:`Request <Request>` is part of a redirect chain (disables history
106 #: and HTTPError storage).
107 self.redirect = redirect
108
109 #: Set to True if full redirects are allowed (e.g. re-POST-ing of data at new ``Location``)
110 self.allow_redirects = allow_redirects
111
112 # Dictionary mapping protocol to the URL of the proxy (e.g. {'http': 'foo.bar:3128'})
113 self.proxies = dict(proxies or [])
114
115 for proxy_type, uri_ref in list(self.proxies.items()):
116 if not uri_ref:
117 del self.proxies[proxy_type]
118
119 # If no proxies are given, allow configuration by environment variables
120 # HTTP_PROXY and HTTPS_PROXY.
121 if not self.proxies and self.config.get('trust_env'):
122 self.proxies = get_environ_proxies()
123
124 self.data = data
125 self.params = params
126 self.files = files
127
128 #: :class:`Response <Response>` instance, containing
129 #: content and metadata of HTTP Response, once :attr:`sent <send>`.
130 self.response = Response()
131
132 #: Authentication tuple or object to attach to :class:`Request <Request>`.
133 self.auth = auth
134
135 #: CookieJar to attach to :class:`Request <Request>`.
136 if isinstance(cookies, cookielib.CookieJar):
137 self.cookies = cookies
138 else:
139 self.cookies = cookiejar_from_dict(cookies)
140
141 #: True if Request has been sent.
142 self.sent = False
143
144 #: Event-handling hooks.
145 self.hooks = {}
146
147 for event in HOOKS:
148 self.hooks[event] = []
149
150 hooks = hooks or {}
151
152 for (k, v) in list(hooks.items()):
153 self.register_hook(event=k, hook=v)
154
155 #: Session.
156 self.session = session
157
158 #: SSL Verification.
159 self.verify = verify
160
161 #: SSL Certificate
162 self.cert = cert
163
164 #: Prefetch response content
165 self.prefetch = prefetch
166
167 if headers:
168 headers = CaseInsensitiveDict(self.headers)
169 else:
170 headers = CaseInsensitiveDict()
171
172 # Add configured base headers.
173 for (k, v) in list(self.config.get('base_headers', {}).items()):
174 if k not in headers:
175 headers[k] = v
176
177 self.headers = headers
178 self._poolmanager = _poolmanager
179
180 def __repr__(self):
181 return '<Request [%s]>' % (self.method)
182
183 def _build_response(self, resp):
184 """Build internal :class:`Response <Response>` object
185 from given response.
186 """
187
188 def build(resp):
189
190 response = Response()
191
192 # Pass settings over.
193 response.config = self.config
194
195 if resp:
196
197 # Fallback to None if there's no status_code, for whatever reason.
198 response.status_code = getattr(resp, 'status', None)
199
200 # Make headers case-insensitive.
201 response.headers = CaseInsensitiveDict(getattr(resp, 'headers', {}))
202
203 # Set encoding.
204 response.encoding = get_encoding_from_headers(response.headers)
205
206 # Add new cookies from the server. Don't if configured not to
207 if self.config.get('store_cookies'):
208 extract_cookies_to_jar(self.cookies, self, resp)
209
210 # Save cookies in Response.
211 response.cookies = self.cookies
212
213 # Save cookies in Session.
214 for cookie in self.cookies:
215 self.session.cookies.set_cookie(cookie)
216
217 # No exceptions were harmed in the making of this request.
218 response.error = getattr(resp, 'error', None)
219
220 # Save original response for later.
221 response.raw = resp
222 if isinstance(self.full_url, bytes):
223 response.url = self.full_url.decode('utf-8')
224 else:
225 response.url = self.full_url
226
227 return response
228
229 history = []
230
231 r = build(resp)
232
233 if r.status_code in REDIRECT_STATI and not self.redirect:
234
235 while (('location' in r.headers) and
236 ((r.status_code is codes.see_other) or (self.allow_redirects))):
237
238 r.content # Consume socket so it can be released
239
240 if not len(history) < self.config.get('max_redirects'):
241 raise TooManyRedirects()
242
243 # Release the connection back into the pool.
244 r.raw.release_conn()
245
246 history.append(r)
247
248 url = r.headers['location']
249 data = self.data
250 files = self.files
251
252 # Handle redirection without scheme (see: RFC 1808 Section 4)
253 if url.startswith('//'):
254 parsed_rurl = urlparse(r.url)
255 url = '%s:%s' % (parsed_rurl.scheme, url)
256
257 # Facilitate non-RFC2616-compliant 'location' headers
258 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
259 if not urlparse(url).netloc:
260 url = urljoin(r.url,
261 # Compliant with RFC3986, we percent
262 # encode the url.
263 requote_uri(url))
264
265 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
266 if r.status_code is codes.see_other:
267 method = 'GET'
268 data = None
269 files = None
270 else:
271 method = self.method
272
273 # Do what the browsers do if strict_mode is off...
274 if (not self.config.get('strict_mode')):
275
276 if r.status_code in (codes.moved, codes.found) and self.method == 'POST':
277 method = 'GET'
278 data = None
279 files = None
280
281 if (r.status_code == 303) and self.method != 'HEAD':
282 method = 'GET'
283 data = None
284 files = None
285
286 # Remove the cookie headers that were sent.
287 headers = self.headers
288 try:
289 del headers['Cookie']
290 except KeyError:
291 pass
292
293 request = Request(
294 url=url,
295 headers=headers,
296 files=files,
297 method=method,
298 params=self.session.params,
299 auth=self.auth,
300 cookies=self.cookies,
301 redirect=True,
302 data=data,
303 config=self.config,
304 timeout=self.timeout,
305 _poolmanager=self._poolmanager,
306 proxies=self.proxies,
307 verify=self.verify,
308 session=self.session,
309 cert=self.cert,
310 prefetch=self.prefetch,
311 )
312
313 request.send()
314 r = request.response
315
316 r.history = history
317
318 self.response = r
319 self.response.request = self
320
321 @staticmethod
322 def _encode_params(data):
323 """Encode parameters in a piece of data.
324
325 Will successfully encode parameters when passed as a dict or a list of
326 2-tuples. Order is retained if data is a list of 2-tuples but abritrary
327 if parameters are supplied as a dict.
328 """
329
330 if isinstance(data, (str, bytes)):
331 return data
332 elif hasattr(data, 'read'):
333 return data
334 elif hasattr(data, '__iter__'):
335 result = []
336 for k, vs in to_key_val_list(data):
337 for v in isinstance(vs, list) and vs or [vs]:
338 if v is not None:
339 result.append(
340 (k.encode('utf-8') if isinstance(k, str) else k,
341 v.encode('utf-8') if isinstance(v, str) else v))
342 return urlencode(result, doseq=True)
343 else:
344 return data
345
346 def _encode_files(self, files):
347 """Build the body for a multipart/form-data request.
348
349 Will successfully encode files when passed as a dict or a list of
350 2-tuples. Order is retained if data is a list of 2-tuples but abritrary
351 if parameters are supplied as a dict.
352
353 """
354 if (not files) or isinstance(self.data, str):
355 return None
356
357 new_fields = []
358 fields = to_key_val_list(self.data)
359 files = to_key_val_list(files)
360
361 for field, val in fields:
362 if isinstance(val, list):
363 for v in val:
364 new_fields.append((field, builtin_str(v)))
365 else:
366 new_fields.append((field, builtin_str(val)))
367
368 for (k, v) in files:
369 # support for explicit filename
370 if isinstance(v, (tuple, list)):
371 fn, fp = v
372 else:
373 fn = guess_filename(v) or k
374 fp = v
375 if isinstance(fp, str):
376 fp = StringIO(fp)
377 if isinstance(fp, bytes):
378 fp = BytesIO(fp)
379 new_fields.append((k, (fn, fp.read())))
380
381 body, content_type = encode_multipart_formdata(new_fields)
382
383 return body, content_type
384
385 @property
386 def full_url(self):
387 """Build the actual URL to use."""
388
389 if not self.url:
390 raise URLRequired()
391
392 url = self.url
393
394 # Support for unicode domain names and paths.
395 scheme, netloc, path, params, query, fragment = urlparse(url)
396
397 if not scheme:
398 raise MissingSchema("Invalid URL %r: No schema supplied" % url)
399
400 if not scheme in SCHEMAS:
401 raise InvalidSchema("Invalid scheme %r" % scheme)
402
403 try:
404 netloc = netloc.encode('idna').decode('utf-8')
405 except UnicodeError:
406 raise InvalidURL('URL has an invalid label.')
407
408 if not path:
409 path = '/'
410
411 if is_py2:
412 if isinstance(scheme, str):
413 scheme = scheme.encode('utf-8')
414 if isinstance(netloc, str):
415 netloc = netloc.encode('utf-8')
416 if isinstance(path, str):
417 path = path.encode('utf-8')
418 if isinstance(params, str):
419 params = params.encode('utf-8')
420 if isinstance(query, str):
421 query = query.encode('utf-8')
422 if isinstance(fragment, str):
423 fragment = fragment.encode('utf-8')
424
425 enc_params = self._encode_params(self.params)
426 if enc_params:
427 if query:
428 query = '%s&%s' % (query, enc_params)
429 else:
430 query = enc_params
431
432 url = (urlunparse([scheme, netloc, path, params, query, fragment]))
433
434 if self.config.get('encode_uri', True):
435 url = requote_uri(url)
436
437 return url
438
439 @property
440 def path_url(self):
441 """Build the path URL to use."""
442
443 url = []
444
445 p = urlsplit(self.full_url)
446
447 # Proxies use full URLs.
448 if p.scheme in self.proxies:
449 url_base, frag = urldefrag(self.full_url)
450 return url_base
451
452
453 path = p.path
454 if not path:
455 path = '/'
456
457 url.append(path)
458
459 query = p.query
460 if query:
461 url.append('?')
462 url.append(query)
463
464 return ''.join(url)
465
466 def register_hook(self, event, hook):
467 """Properly register a hook."""
468 if callable(hook):
469 self.hooks[event].append(hook)
470 elif hasattr(hook, '__iter__'):
471 self.hooks[event].extend(h for h in hook if callable(h))
472
473 def deregister_hook(self, event, hook):
474 """Deregister a previously registered hook.
475 Returns True if the hook existed, False if not.
476 """
477
478 try:
479 self.hooks[event].remove(hook)
480 return True
481 except ValueError:
482 return False
483
484 def send(self, anyway=False, prefetch=None):
485 """Sends the request. Returns True if successful, False if not.
486 If there was an HTTPError during transmission,
487 self.response.status_code will contain the HTTPError code.
488
489 Once a request is successfully sent, `sent` will equal True.
490
491 :param anyway: If True, request will be sent, even if it has
492 already been sent.
493
494 :param prefetch: If not None, will override the request's own setting
495 for prefetch.
496 """
497
498 # Build the URL
499 url = self.full_url
500
501 # Pre-request hook.
502 r = dispatch_hook('pre_request', self.hooks, self)
503 self.__dict__.update(r.__dict__)
504
505 # Logging
506 if self.config.get('verbose'):
507 self.config.get('verbose').write('%s %s %s\n' % (
508 datetime.now().isoformat(), self.method, url
509 ))
510
511 # Use .netrc auth if none was provided.
512 if not self.auth and self.config.get('trust_env'):
513 self.auth = get_netrc_auth(url)
514
515 if self.auth:
516 if isinstance(self.auth, tuple) and len(self.auth) == 2:
517 # special-case basic HTTP auth
518 self.auth = HTTPBasicAuth(*self.auth)
519
520 # Allow auth to make its changes.
521 r = self.auth(self)
522
523 # Update self to reflect the auth changes.
524 self.__dict__.update(r.__dict__)
525
526 # Nottin' on you.
527 body = None
528 content_type = None
529
530 # Multi-part file uploads.
531 if self.files:
532 (body, content_type) = self._encode_files(self.files)
533 else:
534 if self.data:
535
536 body = self._encode_params(self.data)
537 if isinstance(self.data, str) or isinstance(self.data, builtin_str) or hasattr(self.data, 'read'):
538 content_type = None
539 else:
540 content_type = 'application/x-www-form-urlencoded'
541
542 # Add content-type if it wasn't explicitly provided.
543 if (content_type) and (not 'content-type' in self.headers):
544 self.headers['Content-Type'] = content_type
545
546 _p = urlparse(url)
547 no_proxy = filter(lambda x: x.strip(), self.proxies.get('no', '').split(','))
548 proxy = self.proxies.get(_p.scheme)
549
550 if proxy and not any(map(_p.hostname.endswith, no_proxy)):
551 conn = poolmanager.proxy_from_url(proxy)
552 _proxy = urlparse(proxy)
553 if '@' in _proxy.netloc:
554 auth, url = _proxy.netloc.split('@', 1)
555 self.proxy_auth = HTTPProxyAuth(*auth.split(':', 1))
556 r = self.proxy_auth(self)
557 self.__dict__.update(r.__dict__)
558 else:
559 # Check to see if keep_alive is allowed.
560 try:
561 if self.config.get('keep_alive'):
562 conn = self._poolmanager.connection_from_url(url)
563 else:
564 conn = connectionpool.connection_from_url(url)
565 self.headers['Connection'] = 'close'
566 except LocationParseError as e:
567 raise InvalidURL(e)
568
569 if url.startswith('https') and self.verify:
570
571 cert_loc = None
572
573 # Allow self-specified cert location.
574 if self.verify is not True:
575 cert_loc = self.verify
576
577 # Look for configuration.
578 if not cert_loc and self.config.get('trust_env'):
579 cert_loc = os.environ.get('REQUESTS_CA_BUNDLE')
580
581 # Curl compatibility.
582 if not cert_loc and self.config.get('trust_env'):
583 cert_loc = os.environ.get('CURL_CA_BUNDLE')
584
585 if not cert_loc:
586 cert_loc = DEFAULT_CA_BUNDLE_PATH
587
588 if not cert_loc:
589 raise Exception("Could not find a suitable SSL CA certificate bundle.")
590
591 conn.cert_reqs = 'CERT_REQUIRED'
592 conn.ca_certs = cert_loc
593 else:
594 conn.cert_reqs = 'CERT_NONE'
595 conn.ca_certs = None
596
597 if self.cert:
598 if len(self.cert) == 2:
599 conn.cert_file = self.cert[0]
600 conn.key_file = self.cert[1]
601 else:
602 conn.cert_file = self.cert
603
604 if not self.sent or anyway:
605
606 # Skip if 'cookie' header is explicitly set.
607 if 'cookie' not in self.headers:
608 cookie_header = get_cookie_header(self.cookies, self)
609 if cookie_header is not None:
610 self.headers['Cookie'] = cookie_header
611
612 # Pre-send hook.
613 r = dispatch_hook('pre_send', self.hooks, self)
614 self.__dict__.update(r.__dict__)
615
616 # catch urllib3 exceptions and throw Requests exceptions
617 try:
618 # Send the request.
619 r = conn.urlopen(
620 method=self.method,
621 url=self.path_url,
622 body=body,
623 headers=self.headers,
624 redirect=False,
625 assert_same_host=False,
626 preload_content=False,
627 decode_content=False,
628 retries=self.config.get('max_retries', 0),
629 timeout=self.timeout,
630 )
631 self.sent = True
632
633 except socket.error as sockerr:
634 raise ConnectionError(sockerr)
635
636 except MaxRetryError as e:
637 raise ConnectionError(e)
638
639 except (_SSLError, _HTTPError) as e:
640 if isinstance(e, _SSLError):
641 raise SSLError(e)
642 elif isinstance(e, TimeoutError):
643 raise Timeout(e)
644 else:
645 raise Timeout('Request timed out.')
646
647 # build_response can throw TooManyRedirects
648 self._build_response(r)
649
650 # Response manipulation hook.
651 self.response = dispatch_hook('response', self.hooks, self.response)
652
653 # Post-request hook.
654 r = dispatch_hook('post_request', self.hooks, self)
655 self.__dict__.update(r.__dict__)
656
657 # If prefetch is True, mark content as consumed.
658 if prefetch is None:
659 prefetch = self.prefetch
660 if prefetch:
661 # Save the response.
662 self.response.content
663
664 if self.config.get('danger_mode'):
665 self.response.raise_for_status()
666
667 return self.sent
668
669
670class Response(object):
671 """The core :class:`Response <Response>` object. All
672 :class:`Request <Request>` objects contain a
673 :class:`response <Response>` attribute, which is an instance
674 of this class.
675 """
676
677 def __init__(self):
678
679 self._content = False
680 self._content_consumed = False
681
682 #: Integer Code of responded HTTP Status.
683 self.status_code = None
684
685 #: Case-insensitive Dictionary of Response Headers.
686 #: For example, ``headers['content-encoding']`` will return the
687 #: value of a ``'Content-Encoding'`` response header.
688 self.headers = CaseInsensitiveDict()
689
690 #: File-like object representation of response (for advanced usage).
691 self.raw = None
692
693 #: Final URL location of Response.
694 self.url = None
695
696 #: Resulting :class:`HTTPError` of request, if one occurred.
697 self.error = None
698
699 #: Encoding to decode with when accessing r.text.
700 self.encoding = None
701
702 #: A list of :class:`Response <Response>` objects from
703 #: the history of the Request. Any redirect responses will end
704 #: up here. The list is sorted from the oldest to the most recent request.
705 self.history = []
706
707 #: The :class:`Request <Request>` that created the Response.
708 self.request = None
709
710 #: A CookieJar of Cookies the server sent back.
711 self.cookies = None
712
713 #: Dictionary of configurations for this request.
714 self.config = {}
715
716 def __repr__(self):
717 return '<Response [%s]>' % (self.status_code)
718
719 def __bool__(self):
720 """Returns true if :attr:`status_code` is 'OK'."""
721 return self.ok
722
723 def __nonzero__(self):
724 """Returns true if :attr:`status_code` is 'OK'."""
725 return self.ok
726
727 @property
728 def ok(self):
729 try:
730 self.raise_for_status()
731 except RequestException:
732 return False
733 return True
734
735 def iter_content(self, chunk_size=1, decode_unicode=False):
736 """Iterates over the response data. This avoids reading the content
737 at once into memory for large responses. The chunk size is the number
738 of bytes it should read into memory. This is not necessarily the
739 length of each item returned as decoding can take place.
740 """
741 if self._content_consumed:
742 # simulate reading small chunks of the content
743 return iter_slices(self._content, chunk_size)
744
745 def generate():
746 while 1:
747 chunk = self.raw.read(chunk_size)
748 if not chunk:
749 break
750 yield chunk
751 self._content_consumed = True
752
753 gen = stream_untransfer(generate(), self)
754
755 if decode_unicode:
756 gen = stream_decode_response_unicode(gen, self)
757
758 return gen
759
760 def iter_lines(self, chunk_size=10 * 1024, decode_unicode=None):
761 """Iterates over the response data, one line at a time. This
762 avoids reading the content at once into memory for large
763 responses.
764 """
765
766 pending = None
767
768 for chunk in self.iter_content(
769 chunk_size=chunk_size,
770 decode_unicode=decode_unicode):
771
772 if pending is not None:
773 chunk = pending + chunk
774 lines = chunk.splitlines()
775
776 if lines and lines[-1] and chunk and lines[-1][-1] == chunk[-1]:
777 pending = lines.pop()
778 else:
779 pending = None
780
781 for line in lines:
782 yield line
783
784 if pending is not None:
785 yield pending
786
787 @property
788 def content(self):
789 """Content of the response, in bytes."""
790
791 if self._content is False:
792 # Read the contents.
793 try:
794 if self._content_consumed:
795 raise RuntimeError(
796 'The content for this response was already consumed')
797
798 if self.status_code is 0:
799 self._content = None
800 else:
801 self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
802
803 except AttributeError:
804 self._content = None
805
806 self._content_consumed = True
807 # don't need to release the connection; that's been handled by urllib3
808 # since we exhausted the data.
809 return self._content
810
811 @property
812 def text(self):
813 """Content of the response, in unicode.
814
815 if Response.encoding is None and chardet module is available, encoding
816 will be guessed.
817 """
818
819 # Try charset from content-type
820 content = None
821 encoding = self.encoding
822
823 if not self.content:
824 return str('')
825
826 # Fallback to auto-detected encoding.
827 if self.encoding is None:
828 if chardet is not None:
829 encoding = chardet.detect(self.content)['encoding']
830
831 # Decode unicode from given encoding.
832 try:
833 content = str(self.content, encoding, errors='replace')
834 except (LookupError, TypeError):
835 # A LookupError is raised if the encoding was not found which could
836 # indicate a misspelling or similar mistake.
837 #
838 # A TypeError can be raised if encoding is None
839 #
840 # So we try blindly encoding.
841 content = str(self.content, errors='replace')
842
843 return content
844
845 @property
846 def json(self):
847 """Returns the json-encoded content of a response, if any."""
848
849 if not self.encoding and len(self.content) > 3:
850 # No encoding set. JSON RFC 4627 section 3 states we should expect
851 # UTF-8, -16 or -32. Detect which one to use; If the detection or
852 # decoding fails, fall back to `self.text` (using chardet to make
853 # a best guess).
854 encoding = guess_json_utf(self.content)
855 if encoding is not None:
856 try:
857 return json.loads(self.content.decode(encoding))
858 except (ValueError, UnicodeDecodeError):
859 pass
860 try:
861 return json.loads(self.text or self.content)
862 except ValueError:
863 return None
864
865 @property
866 def links(self):
867 """Returns the parsed header links of the response, if any."""
868
869 header = self.headers['link']
870
871 # l = MultiDict()
872 l = {}
873
874 if header:
875 links = parse_header_links(header)
876
877 for link in links:
878 key = link.get('rel') or link.get('url')
879 l[key] = link
880
881 return l
882
883 @property
884 def reason(self):
885 """The HTTP Reason for the response."""
886 return self.raw.reason
887
888 def raise_for_status(self, allow_redirects=True):
889 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""
890
891 if self.error:
892 raise self.error
893
894 http_error_msg = ''
895 if 300 <= self.status_code < 400 and not allow_redirects:
896 http_error_msg = '%s Redirection: %s' % (self.status_code, self.reason)
897
898 elif 400 <= self.status_code < 500:
899 http_error_msg = '%s Client Error: %s' % (self.status_code, self.reason)
900
901 elif 500 <= self.status_code < 600:
902 http_error_msg = '%s Server Error: %s' % (self.status_code, self.reason)
903
904 if http_error_msg:
905 http_error = HTTPError(http_error_msg)
906 http_error.response = self
907 raise http_error
0908
=== added directory '.pc/03-use-distro-packages.patch/requests/packages'
=== added file '.pc/03-use-distro-packages.patch/requests/packages/__init__.py'
--- .pc/03-use-distro-packages.patch/requests/packages/__init__.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/packages/__init__.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,3 @@
1from __future__ import absolute_import
2
3from . import urllib3
04
=== added file '.pc/03-use-distro-packages.patch/requests/safe_mode.py'
--- .pc/03-use-distro-packages.patch/requests/safe_mode.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/safe_mode.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,40 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests.safe_mode
5~~~~~~~~~~~~
6
7This module contains a decorator that implements safe_mode.
8
9:copyright: (c) 2012 by Kenneth Reitz.
10:license: ISC, see LICENSE for more details.
11
12"""
13
14from .models import Response
15from .packages.urllib3.response import HTTPResponse
16from .exceptions import RequestException, ConnectionError, HTTPError
17import socket
18
19
20def catch_exceptions_if_in_safe_mode(function):
21 """New implementation of safe_mode. We catch all exceptions at the API level
22 and then return a blank Response object with the error field filled. This decorator
23 wraps request() in api.py.
24 """
25
26 def wrapped(method, url, **kwargs):
27 # if save_mode, we catch exceptions and fill error field
28 if (kwargs.get('config') and kwargs.get('config').get('safe_mode')) or (kwargs.get('session')
29 and kwargs.get('session').config.get('safe_mode')):
30 try:
31 return function(method, url, **kwargs)
32 except (RequestException, ConnectionError, HTTPError,
33 socket.timeout, socket.gaierror) as e:
34 r = Response()
35 r.error = e
36 r.raw = HTTPResponse() # otherwise, tests fail
37 r.status_code = 0 # with this status_code, content returns None
38 return r
39 return function(method, url, **kwargs)
40 return wrapped
041
=== added file '.pc/03-use-distro-packages.patch/requests/sessions.py'
--- .pc/03-use-distro-packages.patch/requests/sessions.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/requests/sessions.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,328 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests.session
5~~~~~~~~~~~~~~~~
6
7This module provides a Session object to manage and persist settings across
8requests (cookies, auth, proxies).
9
10"""
11
12from copy import deepcopy
13from .compat import cookielib
14from .cookies import cookiejar_from_dict, remove_cookie_by_name
15from .defaults import defaults
16from .models import Request
17from .hooks import dispatch_hook
18from .utils import header_expand, from_key_val_list
19from .packages.urllib3.poolmanager import PoolManager
20
21
22def merge_kwargs(local_kwarg, default_kwarg):
23 """Merges kwarg dictionaries.
24
25 If a local key in the dictionary is set to None, it will be removed.
26 """
27
28 if default_kwarg is None:
29 return local_kwarg
30
31 if isinstance(local_kwarg, str):
32 return local_kwarg
33
34 if local_kwarg is None:
35 return default_kwarg
36
37 # Bypass if not a dictionary (e.g. timeout)
38 if not hasattr(default_kwarg, 'items'):
39 return local_kwarg
40
41 default_kwarg = from_key_val_list(default_kwarg)
42 local_kwarg = from_key_val_list(local_kwarg)
43
44 # Update new values.
45 kwargs = default_kwarg.copy()
46 kwargs.update(local_kwarg)
47
48 # Remove keys that are set to None.
49 for (k, v) in local_kwarg.items():
50 if v is None:
51 del kwargs[k]
52
53 return kwargs
54
55
56class Session(object):
57 """A Requests session."""
58
59 __attrs__ = [
60 'headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks',
61 'params', 'config', 'verify', 'cert', 'prefetch']
62
63 def __init__(self,
64 headers=None,
65 cookies=None,
66 auth=None,
67 timeout=None,
68 proxies=None,
69 hooks=None,
70 params=None,
71 config=None,
72 prefetch=True,
73 verify=True,
74 cert=None):
75
76 self.headers = from_key_val_list(headers or [])
77 self.auth = auth
78 self.timeout = timeout
79 self.proxies = from_key_val_list(proxies or [])
80 self.hooks = from_key_val_list(hooks or {})
81 self.params = from_key_val_list(params or [])
82 self.config = from_key_val_list(config or {})
83 self.prefetch = prefetch
84 self.verify = verify
85 self.cert = cert
86
87 for (k, v) in list(defaults.items()):
88 self.config.setdefault(k, deepcopy(v))
89
90 self.init_poolmanager()
91
92 # Set up a CookieJar to be used by default
93 if isinstance(cookies, cookielib.CookieJar):
94 self.cookies = cookies
95 else:
96 self.cookies = cookiejar_from_dict(cookies)
97
98 def init_poolmanager(self):
99 self.poolmanager = PoolManager(
100 num_pools=self.config.get('pool_connections'),
101 maxsize=self.config.get('pool_maxsize')
102 )
103
104 def __repr__(self):
105 return '<requests-client at 0x%x>' % (id(self))
106
107 def __enter__(self):
108 return self
109
110 def __exit__(self, *args):
111 self.close()
112
113 def close(self):
114 """Dispose of any internal state.
115
116 Currently, this just closes the PoolManager, which closes pooled
117 connections.
118 """
119 self.poolmanager.clear()
120
121 def request(self, method, url,
122 params=None,
123 data=None,
124 headers=None,
125 cookies=None,
126 files=None,
127 auth=None,
128 timeout=None,
129 allow_redirects=True,
130 proxies=None,
131 hooks=None,
132 return_response=True,
133 config=None,
134 prefetch=None,
135 verify=None,
136 cert=None):
137
138 """Constructs and sends a :class:`Request <Request>`.
139 Returns :class:`Response <Response>` object.
140
141 :param method: method for the new :class:`Request` object.
142 :param url: URL for the new :class:`Request` object.
143 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.
144 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
145 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.
146 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.
147 :param files: (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
148 :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth.
149 :param timeout: (optional) Float describing the timeout of the request.
150 :param allow_redirects: (optional) Boolean. Set to True by default.
151 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
152 :param return_response: (optional) If False, an un-sent Request object will returned.
153 :param config: (optional) A configuration dictionary. See ``request.defaults`` for allowed keys and their default values.
154 :param prefetch: (optional) whether to immediately download the response content. Defaults to ``True``.
155 :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.
156 :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
157 """
158
159 method = str(method).upper()
160
161 # Default empty dicts for dict params.
162 data = [] if data is None else data
163 files = [] if files is None else files
164 headers = {} if headers is None else headers
165 params = {} if params is None else params
166 hooks = {} if hooks is None else hooks
167 prefetch = prefetch if prefetch is not None else self.prefetch
168
169 # use session's hooks as defaults
170 for key, cb in list(self.hooks.items()):
171 hooks.setdefault(key, cb)
172
173 # Expand header values.
174 if headers:
175 for k, v in list(headers.items() or {}):
176 headers[k] = header_expand(v)
177
178 args = dict(
179 method=method,
180 url=url,
181 data=data,
182 params=from_key_val_list(params),
183 headers=from_key_val_list(headers),
184 cookies=cookies,
185 files=files,
186 auth=auth,
187 hooks=from_key_val_list(hooks),
188 timeout=timeout,
189 allow_redirects=allow_redirects,
190 proxies=from_key_val_list(proxies),
191 config=from_key_val_list(config),
192 prefetch=prefetch,
193 verify=verify,
194 cert=cert,
195 _poolmanager=self.poolmanager
196 )
197
198 # merge session cookies into passed-in ones
199 dead_cookies = None
200 # passed-in cookies must become a CookieJar:
201 if not isinstance(cookies, cookielib.CookieJar):
202 args['cookies'] = cookiejar_from_dict(cookies)
203 # support unsetting cookies that have been passed in with None values
204 # this is only meaningful when `cookies` is a dict ---
205 # for a real CookieJar, the client should use session.cookies.clear()
206 if cookies is not None:
207 dead_cookies = [name for name in cookies if cookies[name] is None]
208 # merge the session's cookies into the passed-in cookies:
209 for cookie in self.cookies:
210 args['cookies'].set_cookie(cookie)
211 # remove the unset cookies from the jar we'll be using with the current request
212 # (but not from the session's own store of cookies):
213 if dead_cookies is not None:
214 for name in dead_cookies:
215 remove_cookie_by_name(args['cookies'], name)
216
217 # Merge local kwargs with session kwargs.
218 for attr in self.__attrs__:
219 # we already merged cookies:
220 if attr == 'cookies':
221 continue
222
223 session_val = getattr(self, attr, None)
224 local_val = args.get(attr)
225 args[attr] = merge_kwargs(local_val, session_val)
226
227 # Arguments manipulation hook.
228 args = dispatch_hook('args', args['hooks'], args)
229
230 # Create the (empty) response.
231 r = Request(**args)
232
233 # Give the response some context.
234 r.session = self
235
236 # Don't send if asked nicely.
237 if not return_response:
238 return r
239
240 # Send the HTTP Request.
241 r.send(prefetch=prefetch)
242
243 # Return the response.
244 return r.response
245
246 def get(self, url, **kwargs):
247 """Sends a GET request. Returns :class:`Response` object.
248
249 :param url: URL for the new :class:`Request` object.
250 :param \*\*kwargs: Optional arguments that ``request`` takes.
251 """
252
253 kwargs.setdefault('allow_redirects', True)
254 return self.request('get', url, **kwargs)
255
256 def options(self, url, **kwargs):
257 """Sends a OPTIONS request. Returns :class:`Response` object.
258
259 :param url: URL for the new :class:`Request` object.
260 :param \*\*kwargs: Optional arguments that ``request`` takes.
261 """
262
263 kwargs.setdefault('allow_redirects', True)
264 return self.request('options', url, **kwargs)
265
266 def head(self, url, **kwargs):
267 """Sends a HEAD request. Returns :class:`Response` object.
268
269 :param url: URL for the new :class:`Request` object.
270 :param \*\*kwargs: Optional arguments that ``request`` takes.
271 """
272
273 kwargs.setdefault('allow_redirects', False)
274 return self.request('head', url, **kwargs)
275
276 def post(self, url, data=None, **kwargs):
277 """Sends a POST request. Returns :class:`Response` object.
278
279 :param url: URL for the new :class:`Request` object.
280 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
281 :param \*\*kwargs: Optional arguments that ``request`` takes.
282 """
283
284 return self.request('post', url, data=data, **kwargs)
285
286 def put(self, url, data=None, **kwargs):
287 """Sends a PUT request. Returns :class:`Response` object.
288
289 :param url: URL for the new :class:`Request` object.
290 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
291 :param \*\*kwargs: Optional arguments that ``request`` takes.
292 """
293
294 return self.request('put', url, data=data, **kwargs)
295
296 def patch(self, url, data=None, **kwargs):
297 """Sends a PATCH request. Returns :class:`Response` object.
298
299 :param url: URL for the new :class:`Request` object.
300 :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`.
301 :param \*\*kwargs: Optional arguments that ``request`` takes.
302 """
303
304 return self.request('patch', url, data=data, **kwargs)
305
306 def delete(self, url, **kwargs):
307 """Sends a DELETE request. Returns :class:`Response` object.
308
309 :param url: URL for the new :class:`Request` object.
310 :param \*\*kwargs: Optional arguments that ``request`` takes.
311 """
312
313 return self.request('delete', url, **kwargs)
314
315 def __getstate__(self):
316 return dict((attr, getattr(self, attr, None)) for attr in self.__attrs__)
317
318 def __setstate__(self, state):
319 for attr, value in state.items():
320 setattr(self, attr, value)
321
322 self.init_poolmanager()
323
324
325def session(**kwargs):
326 """Returns a :class:`Session` for context-management."""
327
328 return Session(**kwargs)
0329
=== added file '.pc/03-use-distro-packages.patch/setup.py'
--- .pc/03-use-distro-packages.patch/setup.py 1970-01-01 00:00:00 +0000
+++ .pc/03-use-distro-packages.patch/setup.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,73 @@
1#!/usr/bin/env python
2
3import os
4import sys
5
6import requests
7from requests.compat import is_py2
8
9try:
10 from setuptools import setup
11except ImportError:
12 from distutils.core import setup
13
14if sys.argv[-1] == 'publish':
15 os.system('python setup.py sdist upload')
16 sys.exit()
17
18os.environ['PYTHONDONTWRITEBYTECODE'] = '1'
19
20packages = [
21 'requests',
22 'requests.packages',
23 'requests.packages.urllib3',
24 'requests.packages.urllib3.packages',
25 'requests.packages.urllib3.packages.ssl_match_hostname'
26]
27
28if is_py2:
29 packages.extend([
30 'requests.packages.oauthlib',
31 'requests.packages.oauthlib.oauth1',
32 'requests.packages.oauthlib.oauth1.rfc5849',
33 'requests.packages.oauthlib.oauth2',
34 'requests.packages.oauthlib.oauth2.draft25',
35 'requests.packages.chardet',
36 ])
37else:
38 packages.append('requests.packages.chardet2')
39
40requires = []
41
42setup(
43 name='requests',
44 version=requests.__version__,
45 description='Python HTTP for Humans.',
46 long_description=open('README.rst').read() + '\n\n' +
47 open('HISTORY.rst').read(),
48 author='Kenneth Reitz',
49 author_email='me@kennethreitz.com',
50 url='http://python-requests.org',
51 packages=packages,
52 package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']},
53 package_dir={'requests': 'requests'},
54 include_package_data=True,
55 install_requires=requires,
56 license=open('LICENSE').read(),
57 classifiers=(
58 'Development Status :: 5 - Production/Stable',
59 'Intended Audience :: Developers',
60 'Natural Language :: English',
61 'License :: OSI Approved :: ISC License (ISCL)',
62 'Programming Language :: Python',
63 'Programming Language :: Python :: 2.6',
64 'Programming Language :: Python :: 2.7',
65 'Programming Language :: Python :: 3',
66 'Programming Language :: Python :: 3.0',
67 'Programming Language :: Python :: 3.1',
68 'Programming Language :: Python :: 3.2',
69 'Programming Language :: Python :: 3.3',
70 ),
71)
72
73del os.environ['PYTHONDONTWRITEBYTECODE']
074
=== added file '.pc/applied-patches'
--- .pc/applied-patches 1970-01-01 00:00:00 +0000
+++ .pc/applied-patches 2013-01-28 21:17:21 +0000
@@ -0,0 +1,2 @@
102_do-not-use-embedded-python-six.patch
203-use-distro-packages.patch
03
=== modified file 'HISTORY.rst'
--- HISTORY.rst 2011-11-25 00:02:28 +0000
+++ HISTORY.rst 2013-01-28 21:17:21 +0000
@@ -1,10 +1,306 @@
1.. :changelog:
2
1History3History
2-------4-------
35
60.14.2 (2012-10-27)
7+++++++++++++++++++
8
9- Improved mime-compatible JSON handling
10- Proxy fixes
11- Path hack fixes
12- Case-Insensistive Content-Encoding headers
13- Support for CJK parameters in form posts
14
15
160.14.1 (2012-10-01)
17+++++++++++++++++++
18
19- Python 3.3 Compatibility
20- Simply default accept-encoding
21- Bugfixes
22
23
240.14.0 (2012-09-02)
25++++++++++++++++++++
26
27- No more iter_content errors if already downloaded.
28
290.13.9 (2012-08-25)
30+++++++++++++++++++
31
32- Fix for OAuth + POSTs
33- Remove exception eating from dispatch_hook
34- General bugfixes
35
360.13.8 (2012-08-21)
37+++++++++++++++++++
38
39- Incredible Link header support :)
40
410.13.7 (2012-08-19)
42+++++++++++++++++++
43
44- Support for (key, value) lists everywhere.
45- Digest Authentication improvements.
46- Ensure proxy exclusions work properly.
47- Clearer UnicodeError exceptions.
48- Automatic casting of URLs to tsrings (fURL and such)
49- Bugfixes.
50
510.13.6 (2012-08-06)
52+++++++++++++++++++
53
54- Long awaited fix for hanging connections!
55
560.13.5 (2012-07-27)
57+++++++++++++++++++
58
59- Packaging fix
60
610.13.4 (2012-07-27)
62+++++++++++++++++++
63
64- GSSAPI/Kerberos authentication!
65- App Engine 2.7 Fixes!
66- Fix leaking connections (from urllib3 update)
67- OAuthlib path hack fix
68- OAuthlib URL parameters fix.
69
700.13.3 (2012-07-12)
71+++++++++++++++++++
72
73- Use simplejson if available.
74- Do not hide SSLErrors behind Timeouts.
75- Fixed param handling with urls containing fragments.
76- Significantly improved information in User Agent.
77- client certificates are ignored when verify=False
78
790.13.2 (2012-06-28)
80+++++++++++++++++++
81
82- Zero dependencies (once again)!
83- New: Response.reason
84- Sign querystring parameters in OAuth 1.0
85- Client certificates no longer ignored when verify=False
86- Add openSUSE certificate support
87
880.13.1 (2012-06-07)
89+++++++++++++++++++
90
91- Allow passing a file or file-like object as data.
92- Allow hooks to return responses that indicate errors.
93- Fix Response.text and Response.json for body-less responses.
94
950.13.0 (2012-05-29)
96+++++++++++++++++++
97
98- Removal of Requests.async in favor of `grequests <https://github.com/kennethreitz/grequests>`_
99- Allow disabling of cookie persistiance.
100- New implimentation of safe_mode
101- cookies.get now supports default argument
102- Session cookies not saved when Session.request is called with return_response=False
103- Env: no_proxy support.
104- RequestsCookieJar improvements.
105- Various bug fixes.
106
1070.12.1 (2012-05-08)
108+++++++++++++++++++
109
110- New ``Response.json`` property.
111- Ability to add string file uploads.
112- Fix out-of-range issue with iter_lines.
113- Fix iter_content default size.
114- Fix POST redirects containing files.
115
1160.12.0 (2012-05-02)
117+++++++++++++++++++
118
119- EXPERIMENTAL OAUTH SUPPORT!
120- Proper CookieJar-backed cookies interface with awesome dict-like interface.
121- Speed fix for non-iterated content chunks.
122- Move ``pre_request`` to a more usable place.
123- New ``pre_send`` hook.
124- Lazily encode data, params, files.
125- Load system Certificate Bundle if ``certify`` isn't available.
126- Cleanups, fixes.
127
1280.11.2 (2012-04-22)
129+++++++++++++++++++
130
131- Attempt to use the OS's certificate bundle if ``certifi`` isn't available.
132- Infinite digest auth redirect fix.
133- Multi-part file upload improvements.
134- Fix decoding of invalid %encodings in URLs.
135- If there is no content in a response don't throw an error the second time that content is attempted to be read.
136- Upload data on redirects.
137
1380.11.1 (2012-03-30)
139+++++++++++++++++++
140
141* POST redirects now break RFC to do what browsers do: Follow up with a GET.
142* New ``strict_mode`` configuration to disable new redirect behavior.
143
144
1450.11.0 (2012-03-14)
146+++++++++++++++++++
147
148* Private SSL Certificate support
149* Remove select.poll from Gevent monkeypatching
150* Remove redundant generator for chunked transfer encoding
151* Fix: Response.ok raises Timeout Exception in safe_mode
152
1530.10.8 (2012-03-09)
154+++++++++++++++++++
155
156* Generate chunked ValueError fix
157* Proxy configuration by environment variables
158* Simplification of iter_lines.
159* New `trust_env` configuration for disabling system/environment hints.
160* Suppress cookie errors.
161
1620.10.7 (2012-03-07)
163+++++++++++++++++++
164
165* `encode_uri` = False
166
1670.10.6 (2012-02-25)
168+++++++++++++++++++
169
170* Allow '=' in cookies.
171
1720.10.5 (2012-02-25)
173+++++++++++++++++++
174
175* Response body with 0 content-length fix.
176* New async.imap.
177* Don't fail on netrc.
178
179
1800.10.4 (2012-02-20)
181+++++++++++++++++++
182
183* Honor netrc.
184
1850.10.3 (2012-02-20)
186+++++++++++++++++++
187
188* HEAD requests don't follow redirects anymore.
189* raise_for_status() doesn't raise for 3xx anymore.
190* Make Session objects picklable.
191* ValueError for invalid schema URLs.
192
1930.10.2 (2012-01-15)
194+++++++++++++++++++
195
196* Vastly improved URL quoting.
197* Additional allowed cookie key values.
198* Attempted fix for "Too many open files" Error
199* Replace unicode errors on first pass, no need for second pass.
200* Append '/' to bare-domain urls before query insertion.
201* Exceptions now inherit from RuntimeError.
202* Binary uploads + auth fix.
203* Bugfixes.
204
205
2060.10.1 (2012-01-23)
207+++++++++++++++++++
208
209* PYTHON 3 SUPPORT!
210* Dropped 2.5 Support. (*Backwards Incompatible*)
211
2120.10.0 (2012-01-21)
213+++++++++++++++++++
214
215* ``Response.content`` is now bytes-only. (*Backwards Incompatible*)
216* New ``Response.text`` is unicode-only.
217* If no ``Response.encoding`` is specified and ``chardet`` is available, ``Respoonse.text`` will guess an encoding.
218* Default to ISO-8859-1 (Western) encoding for "text" subtypes.
219* Removal of `decode_unicode`. (*Backwards Incompatible*)
220* New multiple-hooks system.
221* New ``Response.register_hook`` for registering hooks within the pipeline.
222* ``Response.url`` is now Unicode.
223
2240.9.3 (2012-01-18)
225++++++++++++++++++
226
227* SSL verify=False bugfix (apparent on windows machines).
228
2290.9.2 (2012-01-18)
230++++++++++++++++++
231
232* Asynchronous async.send method.
233* Support for proper chunk streams with boundaries.
234* session argument for Session classes.
235* Print entire hook tracebacks, not just exception instance.
236* Fix response.iter_lines from pending next line.
237* Fix but in HTTP-digest auth w/ URI having query strings.
238* Fix in Event Hooks section.
239* Urllib3 update.
240
241
2420.9.1 (2012-01-06)
243++++++++++++++++++
244
245* danger_mode for automatic Response.raise_for_status()
246* Response.iter_lines refactor
247
2480.9.0 (2011-12-28)
249++++++++++++++++++
250
251* verify ssl is default.
252
253
2540.8.9 (2011-12-28)
255++++++++++++++++++
256
257* Packaging fix.
258
259
2600.8.8 (2011-12-28)
261++++++++++++++++++
262
263* SSL CERT VERIFICATION!
264* Release of Cerifi: Mozilla's cert list.
265* New 'verify' argument for SSL requests.
266* Urllib3 update.
267
2680.8.7 (2011-12-24)
269++++++++++++++++++
270
271* iter_lines last-line truncation fix
272* Force safe_mode for async requests
273* Handle safe_mode exceptions more consistently
274* Fix iteration on null responses in safe_mode
275
2760.8.6 (2011-12-18)
277++++++++++++++++++
278
279* Socket timeout fixes.
280* Proxy Authorization support.
281
2820.8.5 (2011-12-14)
283++++++++++++++++++
284
285* Response.iter_lines!
286
2870.8.4 (2011-12-11)
288++++++++++++++++++
289
290* Prefetch bugfix.
291* Added license to installed version.
292
2930.8.3 (2011-11-27)
294++++++++++++++++++
295
296* Converted auth system to use simpler callable objects.
297* New session parameter to API methods.
298* Display full URL while logging.
299
40.8.2 (2011-11-19)3000.8.2 (2011-11-19)
5++++++++++++++++++301++++++++++++++++++
6302
7* New unicode decoding system, based on overridable `Response.encoding`.303* New Unicode decoding system, based on over-ridable `Response.encoding`.
8* Proper URL slash-quote handling.304* Proper URL slash-quote handling.
9* Cookies with ``[``, ``]``, and ``_`` allowed.305* Cookies with ``[``, ``]``, and ``_`` allowed.
10306
@@ -28,6 +324,7 @@
28* OPTION method324* OPTION method
29* Async pool size throttling325* Async pool size throttling
30* File uploads send real names326* File uploads send real names
327* Vendored in urllib3
31328
320.7.6 (2011-11-07)3290.7.6 (2011-11-07)
33++++++++++++++++++330++++++++++++++++++
@@ -43,7 +340,7 @@
430.7.4 (2011-10-26)3400.7.4 (2011-10-26)
44++++++++++++++++++341++++++++++++++++++
45342
46* Sesion Hooks fix.343* Session Hooks fix.
47344
480.7.3 (2011-10-23)3450.7.3 (2011-10-23)
49++++++++++++++++++346++++++++++++++++++
50347
=== modified file 'LICENSE'
--- LICENSE 2011-06-06 02:11:15 +0000
+++ LICENSE 2013-01-28 21:17:21 +0000
@@ -1,4 +1,4 @@
1Copyright (c) 2011 Kenneth Reitz.1Copyright (c) 2012 Kenneth Reitz.
22
3Permission to use, copy, modify, and/or distribute this software for any3Permission to use, copy, modify, and/or distribute this software for any
4purpose with or without fee is hereby granted, provided that the above4purpose with or without fee is hereby granted, provided that the above
55
=== modified file 'MANIFEST.in'
--- MANIFEST.in 2011-10-19 20:49:39 +0000
+++ MANIFEST.in 2013-01-28 21:17:21 +0000
@@ -1,1 +1,1 @@
1include README.rst LICENSE HISTORY.rst test_requests.py1include README.rst LICENSE NOTICE HISTORY.rst tests/*. requests/cacert.pem
22
=== added file 'NOTICE'
--- NOTICE 1970-01-01 00:00:00 +0000
+++ NOTICE 2013-01-28 21:17:21 +0000
@@ -0,0 +1,116 @@
1Requests includes some vendorized python libraries to ease installation.
2
3Urllib3 License
4===============
5
6This is the MIT license: http://www.opensource.org/licenses/mit-license.php
7
8Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt),
9Modifications copyright 2022 Kenneth Reitz.
10
11Permission is hereby granted, free of charge, to any person obtaining a copy of this
12software and associated documentation files (the "Software"), to deal in the Software
13without restriction, including without limitation the rights to use, copy, modify, merge,
14publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
15to whom the Software is furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all copies or
18substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27
28Chardet License
29===============
30
31This library is free software; you can redistribute it and/or
32modify it under the terms of the GNU Lesser General Public
33License as published by the Free Software Foundation; either
34version 2.1 of the License, or (at your option) any later version.
35
36This library is distributed in the hope that it will be useful,
37but WITHOUT ANY WARRANTY; without even the implied warranty of
38MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39Lesser General Public License for more details.
40
41You should have received a copy of the GNU Lesser General Public
42License along with this library; if not, write to the Free Software
43Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
4402110-1301 USA
45
46
47
48Chardet2 License
49================
50
51This library is free software; you can redistribute it and/or
52modify it under the terms of the GNU Lesser General Public
53License as published by the Free Software Foundation; either
54version 2.1 of the License, or (at your option) any later version.
55
56This library is distributed in the hope that it will be useful,
57but WITHOUT ANY WARRANTY; without even the implied warranty of
58MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
59Lesser General Public License for more details.
60
61You should have received a copy of the GNU Lesser General Public
62License along with this library; if not, write to the Free Software
63Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
6402110-1301 USA
65
66
67
68Bundle of CA Root Certificates
69==============================
70
71This library is free software; you can redistribute it and/or
72modify it under the terms of the GNU Lesser General Public
73License as published by the Free Software Foundation; either
74version 2.1 of the License, or (at your option) any later version.
75
76This library is distributed in the hope that it will be useful,
77but WITHOUT ANY WARRANTY; without even the implied warranty of
78MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79Lesser General Public License for more details.
80
81You should have received a copy of the GNU Lesser General Public
82License along with this library; if not, write to the Free Software
83Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
8402110-1301
85
86
87OAuthlib
88========
89
90Copyright (c) 2011 Idan Gazit and contributors
91All rights reserved.
92
93Redistribution and use in source and binary forms, with or without
94modification, are permitted provided that the following conditions are met:
95
96 1. Redistributions of source code must retain the above copyright notice,
97 this list of conditions and the following disclaimer.
98
99 2. Redistributions in binary form must reproduce the above copyright
100 notice, this list of conditions and the following disclaimer in the
101 documentation and/or other materials provided with the distribution.
102
103 3. Neither the name of this project nor the names of its contributors may
104 be used to endorse or promote products derived from this software without
105 specific prior written permission.
106
107THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
108AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
109IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
110DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
111FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
112DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
113SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
114CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
115OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0117
=== modified file 'PKG-INFO'
--- PKG-INFO 2011-11-25 00:02:28 +0000
+++ PKG-INFO 2013-01-28 21:17:21 +0000
@@ -1,14 +1,30 @@
1Metadata-Version: 1.01Metadata-Version: 1.1
2Name: requests2Name: requests
3Version: 0.8.23Version: 0.14.2
4Summary: Python HTTP for Humans.4Summary: Python HTTP for Humans.
5Home-page: http://python-requests.org5Home-page: http://python-requests.org
6Author: Kenneth Reitz6Author: Kenneth Reitz
7Author-email: me@kennethreitz.com7Author-email: me@kennethreitz.com
8License: ISC8License: Copyright (c) 2012 Kenneth Reitz.
9
10Permission to use, copy, modify, and/or distribute this software for any
11purpose with or without fee is hereby granted, provided that the above
12copyright notice and this permission notice appear in all copies.
13
14THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9Description: Requests: HTTP for Humans21Description: Requests: HTTP for Humans
10 =========================22 =========================
11 23
24
25 .. image:: https://secure.travis-ci.org/kennethreitz/requests.png?branch=develop
26 :target: https://secure.travis-ci.org/kennethreitz/requests
27
12 Requests is an ISC Licensed HTTP library, written in Python, for human28 Requests is an ISC Licensed HTTP library, written in Python, for human
13 beings.29 beings.
14 30
@@ -27,60 +43,32 @@
27 20443 204
28 >>> r.headers['content-type']44 >>> r.headers['content-type']
29 'application/json'45 'application/json'
30 >>> r.content46 >>> r.text
31 ...47 ...
32 48
33 See `the same code, without Requests <https://gist.github.com/973705>`_.49 See `the same code, without Requests <https://gist.github.com/973705>`_.
34 50
35 Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,51 Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
36 **PATCH**, and **DELETE** HTTP requests. You can add headers, form data,
37 multipart files, and parameters with simple Python dictionaries, and access the52 multipart files, and parameters with simple Python dictionaries, and access the
38 response data in the same way. It's powered by httplib, but it does53 response data in the same way. It's powered by httplib and `urllib3
39 all the hard work and crazy hacks for you.54 <https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
55 hacks for you.
40 56
41 57
42 Features58 Features
43 --------59 --------
44 60
45 - Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests.61 - International Domains and URLs
46 - Gevent support for Asyncronous Requests.62 - Keep-Alive & Connection Pooling
47 - Sessions with cookie persistience.63 - Sessions with Cookie Persistence
48 - Basic, Digest, and Custom Authentication support.64 - Browser-style SSL Verification
49 - Automatic form-encoding of dictionaries65 - Basic/Digest Authentication
50 - A simple dictionary interface for request/response cookies.66 - Elegant Key/Value Cookies
51 - Multipart file uploads.67 - Automatic Decompression
52 - Automatc decoding of Unicode, gzip, and deflate responses.68 - Unicode Response Bodies
53 - Full support for unicode URLs and domain names.69 - Multipart File Uploads
54 70 - Connection Timeouts
55 71 - Thread-safety
56 Usage
57 -----
58
59 It couldn't be simpler. ::
60
61 >>> import requests
62 >>> r = requests.get('http://google.com')
63
64
65 HTTPS? Basic Authentication? ::
66
67 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass')
68 >>> r.status_code
69 401
70
71
72 Uh oh, we're not authorized! Let's add authentication. ::
73
74 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass'))
75
76 >>> r.status_code
77 200
78
79 >>> r.headers['content-type']
80 'application/json'
81
82 >>> r.content
83 '{"authenticated": true, "user": "user"}'
84 72
85 73
86 Installation74 Installation
@@ -107,16 +95,312 @@
107 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.95 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.
108 96
109 .. _`the repository`: http://github.com/kennethreitz/requests97 .. _`the repository`: http://github.com/kennethreitz/requests
110 .. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS98 .. _AUTHORS: https://github.com/kennethreitz/requests/blob/develop/AUTHORS.rst
111 99
100
101 .. :changelog:
112 102
113 History103 History
114 -------104 -------
115 105
106 0.14.2 (2012-10-27)
107 +++++++++++++++++++
108
109 - Improved mime-compatible JSON handling
110 - Proxy fixes
111 - Path hack fixes
112 - Case-Insensistive Content-Encoding headers
113 - Support for CJK parameters in form posts
114
115
116 0.14.1 (2012-10-01)
117 +++++++++++++++++++
118
119 - Python 3.3 Compatibility
120 - Simply default accept-encoding
121 - Bugfixes
122
123
124 0.14.0 (2012-09-02)
125 ++++++++++++++++++++
126
127 - No more iter_content errors if already downloaded.
128
129 0.13.9 (2012-08-25)
130 +++++++++++++++++++
131
132 - Fix for OAuth + POSTs
133 - Remove exception eating from dispatch_hook
134 - General bugfixes
135
136 0.13.8 (2012-08-21)
137 +++++++++++++++++++
138
139 - Incredible Link header support :)
140
141 0.13.7 (2012-08-19)
142 +++++++++++++++++++
143
144 - Support for (key, value) lists everywhere.
145 - Digest Authentication improvements.
146 - Ensure proxy exclusions work properly.
147 - Clearer UnicodeError exceptions.
148 - Automatic casting of URLs to tsrings (fURL and such)
149 - Bugfixes.
150
151 0.13.6 (2012-08-06)
152 +++++++++++++++++++
153
154 - Long awaited fix for hanging connections!
155
156 0.13.5 (2012-07-27)
157 +++++++++++++++++++
158
159 - Packaging fix
160
161 0.13.4 (2012-07-27)
162 +++++++++++++++++++
163
164 - GSSAPI/Kerberos authentication!
165 - App Engine 2.7 Fixes!
166 - Fix leaking connections (from urllib3 update)
167 - OAuthlib path hack fix
168 - OAuthlib URL parameters fix.
169
170 0.13.3 (2012-07-12)
171 +++++++++++++++++++
172
173 - Use simplejson if available.
174 - Do not hide SSLErrors behind Timeouts.
175 - Fixed param handling with urls containing fragments.
176 - Significantly improved information in User Agent.
177 - client certificates are ignored when verify=False
178
179 0.13.2 (2012-06-28)
180 +++++++++++++++++++
181
182 - Zero dependencies (once again)!
183 - New: Response.reason
184 - Sign querystring parameters in OAuth 1.0
185 - Client certificates no longer ignored when verify=False
186 - Add openSUSE certificate support
187
188 0.13.1 (2012-06-07)
189 +++++++++++++++++++
190
191 - Allow passing a file or file-like object as data.
192 - Allow hooks to return responses that indicate errors.
193 - Fix Response.text and Response.json for body-less responses.
194
195 0.13.0 (2012-05-29)
196 +++++++++++++++++++
197
198 - Removal of Requests.async in favor of `grequests <https://github.com/kennethreitz/grequests>`_
199 - Allow disabling of cookie persistiance.
200 - New implimentation of safe_mode
201 - cookies.get now supports default argument
202 - Session cookies not saved when Session.request is called with return_response=False
203 - Env: no_proxy support.
204 - RequestsCookieJar improvements.
205 - Various bug fixes.
206
207 0.12.1 (2012-05-08)
208 +++++++++++++++++++
209
210 - New ``Response.json`` property.
211 - Ability to add string file uploads.
212 - Fix out-of-range issue with iter_lines.
213 - Fix iter_content default size.
214 - Fix POST redirects containing files.
215
216 0.12.0 (2012-05-02)
217 +++++++++++++++++++
218
219 - EXPERIMENTAL OAUTH SUPPORT!
220 - Proper CookieJar-backed cookies interface with awesome dict-like interface.
221 - Speed fix for non-iterated content chunks.
222 - Move ``pre_request`` to a more usable place.
223 - New ``pre_send`` hook.
224 - Lazily encode data, params, files.
225 - Load system Certificate Bundle if ``certify`` isn't available.
226 - Cleanups, fixes.
227
228 0.11.2 (2012-04-22)
229 +++++++++++++++++++
230
231 - Attempt to use the OS's certificate bundle if ``certifi`` isn't available.
232 - Infinite digest auth redirect fix.
233 - Multi-part file upload improvements.
234 - Fix decoding of invalid %encodings in URLs.
235 - If there is no content in a response don't throw an error the second time that content is attempted to be read.
236 - Upload data on redirects.
237
238 0.11.1 (2012-03-30)
239 +++++++++++++++++++
240
241 * POST redirects now break RFC to do what browsers do: Follow up with a GET.
242 * New ``strict_mode`` configuration to disable new redirect behavior.
243
244
245 0.11.0 (2012-03-14)
246 +++++++++++++++++++
247
248 * Private SSL Certificate support
249 * Remove select.poll from Gevent monkeypatching
250 * Remove redundant generator for chunked transfer encoding
251 * Fix: Response.ok raises Timeout Exception in safe_mode
252
253 0.10.8 (2012-03-09)
254 +++++++++++++++++++
255
256 * Generate chunked ValueError fix
257 * Proxy configuration by environment variables
258 * Simplification of iter_lines.
259 * New `trust_env` configuration for disabling system/environment hints.
260 * Suppress cookie errors.
261
262 0.10.7 (2012-03-07)
263 +++++++++++++++++++
264
265 * `encode_uri` = False
266
267 0.10.6 (2012-02-25)
268 +++++++++++++++++++
269
270 * Allow '=' in cookies.
271
272 0.10.5 (2012-02-25)
273 +++++++++++++++++++
274
275 * Response body with 0 content-length fix.
276 * New async.imap.
277 * Don't fail on netrc.
278
279
280 0.10.4 (2012-02-20)
281 +++++++++++++++++++
282
283 * Honor netrc.
284
285 0.10.3 (2012-02-20)
286 +++++++++++++++++++
287
288 * HEAD requests don't follow redirects anymore.
289 * raise_for_status() doesn't raise for 3xx anymore.
290 * Make Session objects picklable.
291 * ValueError for invalid schema URLs.
292
293 0.10.2 (2012-01-15)
294 +++++++++++++++++++
295
296 * Vastly improved URL quoting.
297 * Additional allowed cookie key values.
298 * Attempted fix for "Too many open files" Error
299 * Replace unicode errors on first pass, no need for second pass.
300 * Append '/' to bare-domain urls before query insertion.
301 * Exceptions now inherit from RuntimeError.
302 * Binary uploads + auth fix.
303 * Bugfixes.
304
305
306 0.10.1 (2012-01-23)
307 +++++++++++++++++++
308
309 * PYTHON 3 SUPPORT!
310 * Dropped 2.5 Support. (*Backwards Incompatible*)
311
312 0.10.0 (2012-01-21)
313 +++++++++++++++++++
314
315 * ``Response.content`` is now bytes-only. (*Backwards Incompatible*)
316 * New ``Response.text`` is unicode-only.
317 * If no ``Response.encoding`` is specified and ``chardet`` is available, ``Respoonse.text`` will guess an encoding.
318 * Default to ISO-8859-1 (Western) encoding for "text" subtypes.
319 * Removal of `decode_unicode`. (*Backwards Incompatible*)
320 * New multiple-hooks system.
321 * New ``Response.register_hook`` for registering hooks within the pipeline.
322 * ``Response.url`` is now Unicode.
323
324 0.9.3 (2012-01-18)
325 ++++++++++++++++++
326
327 * SSL verify=False bugfix (apparent on windows machines).
328
329 0.9.2 (2012-01-18)
330 ++++++++++++++++++
331
332 * Asynchronous async.send method.
333 * Support for proper chunk streams with boundaries.
334 * session argument for Session classes.
335 * Print entire hook tracebacks, not just exception instance.
336 * Fix response.iter_lines from pending next line.
337 * Fix but in HTTP-digest auth w/ URI having query strings.
338 * Fix in Event Hooks section.
339 * Urllib3 update.
340
341
342 0.9.1 (2012-01-06)
343 ++++++++++++++++++
344
345 * danger_mode for automatic Response.raise_for_status()
346 * Response.iter_lines refactor
347
348 0.9.0 (2011-12-28)
349 ++++++++++++++++++
350
351 * verify ssl is default.
352
353
354 0.8.9 (2011-12-28)
355 ++++++++++++++++++
356
357 * Packaging fix.
358
359
360 0.8.8 (2011-12-28)
361 ++++++++++++++++++
362
363 * SSL CERT VERIFICATION!
364 * Release of Cerifi: Mozilla's cert list.
365 * New 'verify' argument for SSL requests.
366 * Urllib3 update.
367
368 0.8.7 (2011-12-24)
369 ++++++++++++++++++
370
371 * iter_lines last-line truncation fix
372 * Force safe_mode for async requests
373 * Handle safe_mode exceptions more consistently
374 * Fix iteration on null responses in safe_mode
375
376 0.8.6 (2011-12-18)
377 ++++++++++++++++++
378
379 * Socket timeout fixes.
380 * Proxy Authorization support.
381
382 0.8.5 (2011-12-14)
383 ++++++++++++++++++
384
385 * Response.iter_lines!
386
387 0.8.4 (2011-12-11)
388 ++++++++++++++++++
389
390 * Prefetch bugfix.
391 * Added license to installed version.
392
393 0.8.3 (2011-11-27)
394 ++++++++++++++++++
395
396 * Converted auth system to use simpler callable objects.
397 * New session parameter to API methods.
398 * Display full URL while logging.
399
116 0.8.2 (2011-11-19)400 0.8.2 (2011-11-19)
117 ++++++++++++++++++401 ++++++++++++++++++
118 402
119 * New unicode decoding system, based on overridable `Response.encoding`.403 * New Unicode decoding system, based on over-ridable `Response.encoding`.
120 * Proper URL slash-quote handling.404 * Proper URL slash-quote handling.
121 * Cookies with ``[``, ``]``, and ``_`` allowed.405 * Cookies with ``[``, ``]``, and ``_`` allowed.
122 406
@@ -140,6 +424,7 @@
140 * OPTION method424 * OPTION method
141 * Async pool size throttling425 * Async pool size throttling
142 * File uploads send real names426 * File uploads send real names
427 * Vendored in urllib3
143 428
144 0.7.6 (2011-11-07)429 0.7.6 (2011-11-07)
145 ++++++++++++++++++430 ++++++++++++++++++
@@ -155,7 +440,7 @@
155 0.7.4 (2011-10-26)440 0.7.4 (2011-10-26)
156 ++++++++++++++++++441 ++++++++++++++++++
157 442
158 * Sesion Hooks fix.443 * Session Hooks fix.
159 444
160 0.7.3 (2011-10-23)445 0.7.3 (2011-10-23)
161 ++++++++++++++++++446 ++++++++++++++++++
@@ -386,6 +671,10 @@
386Classifier: Natural Language :: English671Classifier: Natural Language :: English
387Classifier: License :: OSI Approved :: ISC License (ISCL)672Classifier: License :: OSI Approved :: ISC License (ISCL)
388Classifier: Programming Language :: Python673Classifier: Programming Language :: Python
389Classifier: Programming Language :: Python :: 2.5
390Classifier: Programming Language :: Python :: 2.6674Classifier: Programming Language :: Python :: 2.6
391Classifier: Programming Language :: Python :: 2.7675Classifier: Programming Language :: Python :: 2.7
676Classifier: Programming Language :: Python :: 3
677Classifier: Programming Language :: Python :: 3.0
678Classifier: Programming Language :: Python :: 3.1
679Classifier: Programming Language :: Python :: 3.2
680Classifier: Programming Language :: Python :: 3.3
392681
=== modified file 'README.rst'
--- README.rst 2011-11-25 00:02:28 +0000
+++ README.rst 2013-01-28 21:17:21 +0000
@@ -1,6 +1,10 @@
1Requests: HTTP for Humans1Requests: HTTP for Humans
2=========================2=========================
33
4
5.. image:: https://secure.travis-ci.org/kennethreitz/requests.png?branch=develop
6 :target: https://secure.travis-ci.org/kennethreitz/requests
7
4Requests is an ISC Licensed HTTP library, written in Python, for human8Requests is an ISC Licensed HTTP library, written in Python, for human
5beings.9beings.
610
@@ -19,60 +23,32 @@
19 20423 204
20 >>> r.headers['content-type']24 >>> r.headers['content-type']
21 'application/json'25 'application/json'
22 >>> r.content26 >>> r.text
23 ...27 ...
2428
25See `the same code, without Requests <https://gist.github.com/973705>`_.29See `the same code, without Requests <https://gist.github.com/973705>`_.
2630
27Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,31Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
28**PATCH**, and **DELETE** HTTP requests. You can add headers, form data,
29multipart files, and parameters with simple Python dictionaries, and access the32multipart files, and parameters with simple Python dictionaries, and access the
30response data in the same way. It's powered by httplib, but it does33response data in the same way. It's powered by httplib and `urllib3
31all the hard work and crazy hacks for you.34<https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
35hacks for you.
3236
3337
34Features38Features
35--------39--------
3640
37- Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests.41- International Domains and URLs
38- Gevent support for Asyncronous Requests.42- Keep-Alive & Connection Pooling
39- Sessions with cookie persistience.43- Sessions with Cookie Persistence
40- Basic, Digest, and Custom Authentication support.44- Browser-style SSL Verification
41- Automatic form-encoding of dictionaries45- Basic/Digest Authentication
42- A simple dictionary interface for request/response cookies.46- Elegant Key/Value Cookies
43- Multipart file uploads.47- Automatic Decompression
44- Automatc decoding of Unicode, gzip, and deflate responses.48- Unicode Response Bodies
45- Full support for unicode URLs and domain names.49- Multipart File Uploads
4650- Connection Timeouts
4751- Thread-safety
48Usage
49-----
50
51It couldn't be simpler. ::
52
53 >>> import requests
54 >>> r = requests.get('http://google.com')
55
56
57HTTPS? Basic Authentication? ::
58
59 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass')
60 >>> r.status_code
61 401
62
63
64Uh oh, we're not authorized! Let's add authentication. ::
65
66 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass'))
67
68 >>> r.status_code
69 200
70
71 >>> r.headers['content-type']
72 'application/json'
73
74 >>> r.content
75 '{"authenticated": true, "user": "user"}'
7652
7753
78Installation54Installation
@@ -99,4 +75,4 @@
99#. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.75#. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.
10076
101.. _`the repository`: http://github.com/kennethreitz/requests77.. _`the repository`: http://github.com/kennethreitz/requests
102.. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS78.. _AUTHORS: https://github.com/kennethreitz/requests/blob/develop/AUTHORS.rst
10379
=== modified file 'debian/changelog'
--- debian/changelog 2011-11-25 00:02:28 +0000
+++ debian/changelog 2013-01-28 21:17:21 +0000
@@ -1,3 +1,140 @@
1requests (0.14.2-0ubuntu1~cloud0) precise-grizzly; urgency=low
2
3 * New upstream release for the Ubuntu Cloud Archvie:
4 - Removed python3 version.
5
6 -- Chuck Short <zulcss@ubuntu.com> Mon, 28 Jan 2013 14:58:12 -0600
7
8requests (0.14.2-0ubuntu1) raring; urgency=low
9
10 * New upstream release (LP: #1076107). Remaining changes:
11 - debian/patches/01_do-not-use-python-certifi.patch: No longer necessary.
12 - debian/patches/02_do-not-use-embedded-python-six.patch: refreshed
13 - debian/patches/03-dont-use-embeded-urllib3.patch: refreshed and
14 renamed to 03-use-distro-packages.patch
15 - debian/control: python-chardet and python3-chardet are now required
16 (i.e. Depends instead of Recommends).
17
18 -- Barry Warsaw <barry@ubuntu.com> Thu, 01 Nov 2012 14:56:00 +0100
19
20requests (0.12.1-1ubuntu6) quantal; urgency=low
21
22 * debian/control: Resolve Depends misspelling of python-urllib3.
23
24 -- Dave Walker (Daviey) <DaveWalker@ubuntu.com> Thu, 13 Sep 2012 14:55:21 +0100
25
26requests (0.12.1-1ubuntu5) quantal; urgency=low
27
28 * Add -r to rm call in debian/rules removing requests/packages/urllib3
29 * Add python3-urllib3 to build-depends and python3-requests depends
30
31 -- Adam Conrad <adconrad@ubuntu.com> Wed, 12 Sep 2012 23:05:13 -0600
32
33requests (0.12.1-1ubuntu4) quantal; urgency=low
34
35 * debian/rules, debian/control,
36 debian/patches/03-dont-use-embeded-urllib3.patch:
37 Don't use embeded python-urllib3.
38
39 -- Chuck Short <zulcss@ubuntu.com> Fri, 07 Sep 2012 09:06:26 -0500
40
41requests (0.12.1-1ubuntu3) quantal; urgency=low
42
43 * d/{rules,control}: Disable tests and drop associated deps; 10/11
44 of them require network connectivity so they break in offline build
45 environments.
46
47 -- James Page <james.page@ubuntu.com> Tue, 14 Aug 2012 12:39:19 +0100
48
49requests (0.12.1-1ubuntu2) quantal; urgency=low
50
51 * debian/control: Fix up testsuite some more.
52
53 -- Chuck Short <zulcss@ubuntu.com> Wed, 18 Jul 2012 14:25:42 -0500
54
55requests (0.12.1-1ubuntu1) quantal; urgency=low
56
57 * debia/rules: Enable test suite.
58
59 -- Chuck Short <zulcss@ubuntu.com> Mon, 11 Jun 2012 09:18:06 -0400
60
61requests (0.12.1-1) unstable; urgency=low
62
63 * New upstream release
64 * debian/control
65 - Added python-oauthlib to python-requests' Recommends field
66 * debian/patches/01_do-not-use-python-certifi.patch
67 - Refreshed
68
69 -- Daniele Tricoli <eriol@mornie.org> Fri, 04 May 2012 14:34:47 +0200
70
71requests (0.11.2-1) unstable; urgency=low
72
73 * New upstream release
74 * debian/patches/01_do-not-use-python-certifi.patch
75 - Refreshed
76
77 -- Daniele Tricoli <eriol@mornie.org> Mon, 23 Apr 2012 16:06:33 +0200
78
79requests (0.11.1-1) unstable; urgency=low
80
81 * New upstream release
82 * debian/control
83 - Added python3-chardet to python3-requests' Recommends field
84 - Updated Description field
85 * debian/patches/02_do-not-use-embedded-python-six.patch
86 - Refreshed
87
88 -- Daniele Tricoli <eriol@mornie.org> Sun, 01 Apr 2012 12:33:42 +0200
89
90requests (0.10.8-1) unstable; urgency=low
91
92 [ Piotr Ożarowski ]
93 * Fix typo in python3-requests' ${python3:Depends}
94
95 [ Daniele Tricoli ]
96 * New upstream release (Closes: #663561)
97 * Removed embedded copy of python-six
98 - Added debian/patches/02_do-not-use-embedded-python-six.patch
99 - Added override_dh_auto_configure to debian/rules to remove
100 the embedded copy
101 - Added python(3)-six to Builds-Depends and Depends
102 * debian/control
103 - Bumped Standards-Version to 3.9.3 (no changes needed)
104 * debian/copyright
105 - Added forgotten stanzas about packages inside the fork
106 of python-urllib3
107 * debian/patches/01_do-not-use-python-certifi.patch
108 - Refreshed
109 * debian/patches/02_fix-python3-except-sintax-error.patch
110 - Removed as it is applied upstream
111
112 -- Daniele Tricoli <eriol@mornie.org> Mon, 19 Mar 2012 01:20:59 +0100
113
114requests (0.10.1-1) unstable; urgency=low
115
116 * New upstream release
117 - Adds Python 3 support
118 * Builded python 3 package
119 * debian/control
120 - Added python-chardet to Recommends
121 - Bumped X-Python-Version >= 2.6
122 - Added ca-certificates to Depends
123 - Added python3-all to Build-Depends
124 * debian/copyright
125 - Updated Format URI
126 - Updated copyright years
127 * debian/patches/01_do-not-use-python-certifi.patch
128 - To verify SSL certificates for HTTPS requests, use the bundle provided by
129 ca-certificates instead of python-certifi
130 * debian/patches/02_fix-python3-except-sintax-error.patches
131 - Fix SyntaxError on Python3 because "except Error, e" is not supported
132 anymore
133 * debian/rules
134 - Added override_dh_auto_clean to make the package build twice in a row
135
136 -- Daniele Tricoli <eriol@mornie.org> Sun, 05 Feb 2012 04:51:38 +0100
137
1requests (0.8.2-1) unstable; urgency=low138requests (0.8.2-1) unstable; urgency=low
2139
3 * New upstream release140 * New upstream release
4141
=== modified file 'debian/control'
--- debian/control 2011-10-19 20:49:39 +0000
+++ debian/control 2013-01-28 21:17:21 +0000
@@ -1,37 +1,52 @@
1Source: requests1Source: requests
2Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>2Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
3XSBC-Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
3Uploaders: Daniele Tricoli <eriol@mornie.org>4Uploaders: Daniele Tricoli <eriol@mornie.org>
4Section: python5Section: python
5Priority: optional6Priority: optional
6Build-Depends: debhelper (>= 7.0.50~),7Build-Depends:
7 python-all (>= 2.6.6-3),8 debhelper (>= 7.0.50~),
8Standards-Version: 3.9.29 python-all (>= 2.6.6-3),
9X-Python-Version: >= 2.510 python-six,
11 python-chardet,
12 python-urllib3,
13 python-gevent,
14 python-oauthlib,
15 ca-certificates
16Standards-Version: 3.9.3
17X-Python-Version: >= 2.6
18X-Python3-Version: >= 3.0
10Homepage: http://python-requests.org19Homepage: http://python-requests.org
11Vcs-Svn: svn://svn.debian.org/python-modules/packages/requests/trunk/20Vcs-Svn: svn://svn.debian.org/python-modules/packages/requests/trunk/
12Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/requests/trunk/21Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/requests/trunk/
1322
14Package: python-requests23Package: python-requests
15Architecture: all24Architecture: all
16Depends: ${misc:Depends}, ${python:Depends}25Depends:
17Recommends: python-gevent26 ${misc:Depends},
27 ${python:Depends},
28 ca-certificates,
29 python-urllib3,
30 python-six,
31 python-chardet
32Recommends:
33 python-gevent,
34 python-oauthlib
18Description: elegant and simple HTTP library for Python, built for human beings35Description: elegant and simple HTTP library for Python, built for human beings
19 Requests allow you to send GET, HEAD, PUT, POST, and DELETE36 Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
20 HTTP requests. You can add headers, form data, multipart files, and37 multipart files, and parameters with simple Python dictionaries, and access the
21 parameters with simple Python dictionaries, and access the response38 response data in the same way. It's powered by httplib and urllib3, but it does
22 data in the same way. It's powered by urllib2, but it does all the39 all the hard work and crazy hacks for you.
23 hard work and crazy hacks for you.
24 .40 .
25 Features41 Features
26 .42 .
27 - Extremely simple GET, HEAD, POST, PUT, DELETE Requests43 - International Domains and URLs
28 - Simple HTTP Header Request Attachment44 - Keep-Alive & Connection Pooling
29 - Simple Data/Params Request Attachment45 - Sessions with Cookie Persistence
30 - Simple Multipart File Uploads46 - Browser-style SSL Verification
31 - CookieJar Support47 - Basic/Digest Authentication
32 - Redirection History48 - Elegant Key/Value Cookies
33 - Proxy Support49 - Automatic Decompression
34 - Redirection Recursion Urllib Fix50 - Unicode Response Bodies
35 - Auto Decompression of GZipped Content51 - Multipart File Uploads
36 - Unicode URL Support52 - Connection Timeouts
37 - Simple Authentication: Simple URL + HTTP Auth Registry
3853
=== modified file 'debian/copyright'
--- debian/copyright 2011-11-25 00:02:28 +0000
+++ debian/copyright 2013-01-28 21:17:21 +0000
@@ -1,18 +1,30 @@
1Format: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=1741Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2Upstream-Name: requests2Upstream-Name: requests
3Upstream-Contact: Kenneth Reitz <me@kennethreitz.com>3Upstream-Contact: Kenneth Reitz <me@kennethreitz.com>
4Source: http://pypi.python.org/pypi/requests4Source: http://pypi.python.org/pypi/requests
55
6Files: *6Files: *
7Copyright: © 2011 Kenneth Reitz7Copyright: 2011-2012, Kenneth Reitz
8License: ISC8License: ISC
99
10Files: requests/packages/urllib3/*10Files: requests/packages/urllib3/*
11Copyright: © 2008-2011 Andrey Petrov11Copyright: 2008-2011, Andrey Petrov
12License: Expat
13
14Files: requests/packages/urllib3/packages/mimetools_choose_boundary/__init__.py
15Copyright: 2010, Python Software Foundation
16License: PSF-2
17
18Files: requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
19Copyright: 2011, Python Software Foundation
20License: PSF-2
21
22Files: requests/packages/urllib3/packages/six.py
23Copyright: 2010-2011, Benjamin Peterson
12License: Expat24License: Expat
1325
14Files: requests/packages/oreos/monkeys.py26Files: requests/packages/oreos/monkeys.py
15Copyright: © 2000 Timothy O'Malley27Copyright: 2000, Timothy O'Malley
16License:28License:
17 Permission to use, copy, modify, and distribute this software29 Permission to use, copy, modify, and distribute this software
18 and its documentation for any purpose and without fee is hereby30 and its documentation for any purpose and without fee is hereby
@@ -33,7 +45,7 @@
33 PERFORMANCE OF THIS SOFTWARE.45 PERFORMANCE OF THIS SOFTWARE.
3446
35Files: debian/*47Files: debian/*
36Copyright: © 2011 Daniele Tricoli <eriol@mornie.org>48Copyright: 2011-2012, Daniele Tricoli <eriol@mornie.org>
37License: ISC49License: ISC
3850
39License: ISC51License: ISC
@@ -68,3 +80,49 @@
68 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,80 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE81 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.82 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
83
84License: PSF-2
85 1. This LICENSE AGREEMENT is between the Python Software Foundation
86 ("PSF"), and the Individual or Organization ("Licensee") accessing
87 and otherwise using this software ("Python") in source or binary form
88 and its associated documentation.
89 .
90 2. Subject to the terms and conditions of this License Agreement, PSF
91 hereby grants Licensee a nonexclusive, royalty-free, world-wide
92 license to reproduce, analyze, test, perform and/or display publicly,
93 prepare derivative works, distribute, and otherwise use Python alone
94 or in any derivative version, provided, however, that PSF's License
95 Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001,
96 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights
97 Reserved" are retained in Python alone or in any derivative version
98 prepared by Licensee.
99 .
100 3. In the event Licensee prepares a derivative work that is based on
101 or incorporates Python or any part thereof, and wants to make the
102 derivative work available to others as provided herein, then Licensee
103 hereby agrees to include in any such work a brief summary of the
104 changes made to Python.
105 .
106 4. PSF is making Python available to Licensee on an "AS IS"
107 basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
108 IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
109 DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR
110 FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
111 INFRINGE ANY THIRD PARTY RIGHTS.
112 .
113 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
114 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
115 RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY
116 DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
117 .
118 6. This License Agreement will automatically terminate upon a
119 material breach of its terms and conditions.
120 .
121 7. Nothing in this License Agreement shall be deemed to create any
122 relationship of agency, partnership, or joint venture between PSF and
123 Licensee. This License Agreement does not grant permission to use PSF
124 trademarks or trade name in a trademark sense to endorse or promote
125 products or services of Licensee, or any third party.
126 .
127 8. By copying, installing or otherwise using Python, Licensee agrees
128 to be bound by the terms and conditions of this License Agreement.
71129
=== added directory 'debian/patches'
=== added file 'debian/patches/02_do-not-use-embedded-python-six.patch'
--- debian/patches/02_do-not-use-embedded-python-six.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/02_do-not-use-embedded-python-six.patch 2013-01-28 21:17:21 +0000
@@ -0,0 +1,51 @@
1Description: Do not use embedded copy of python-six.
2Author: Daniele Tricoli <eriol@mornie.org>
3Forwarded: not-needed
4Last-Update: 2012-03-19
5
6--- a/requests/packages/urllib3/connectionpool.py
7+++ b/requests/packages/urllib3/connectionpool.py
8@@ -52,7 +52,7 @@
9 )
10
11 from .packages.ssl_match_hostname import match_hostname, CertificateError
12-from .packages import six
13+import six
14
15
16 xrange = six.moves.xrange
17--- a/requests/packages/urllib3/filepost.py
18+++ b/requests/packages/urllib3/filepost.py
19@@ -10,8 +10,8 @@
20 from uuid import uuid4
21 from io import BytesIO
22
23-from .packages import six
24-from .packages.six import b
25+import six
26+from six import b
27
28 writer = codecs.lookup('utf-8')[3]
29
30--- a/requests/packages/urllib3/response.py
31+++ b/requests/packages/urllib3/response.py
32@@ -11,7 +11,7 @@
33 from io import BytesIO
34
35 from .exceptions import DecodeError
36-from .packages.six import string_types as basestring
37+from six import string_types as basestring
38
39
40 log = logging.getLogger(__name__)
41--- a/requests/packages/urllib3/util.py
42+++ b/requests/packages/urllib3/util.py
43@@ -18,7 +18,7 @@
44 except ImportError: # `select` doesn't exist on AppEngine.
45 select = False
46
47-from .packages import six
48+import six
49 from .exceptions import LocationParseError
50
51
052
=== added file 'debian/patches/03-use-distro-packages.patch'
--- debian/patches/03-use-distro-packages.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/03-use-distro-packages.patch 2013-01-28 21:17:21 +0000
@@ -0,0 +1,127 @@
1Description: Do not use embeded copy of python-urllib3
2Author: Chuck Short <zulcss@ubuntu.com>
3Forwarded: non-need
4Last-Update: 2012-09-05
5--- a/requests/models.py
6+++ b/requests/models.py
7@@ -18,12 +18,12 @@
8
9 from .auth import HTTPBasicAuth, HTTPProxyAuth
10 from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header
11-from .packages.urllib3.exceptions import MaxRetryError, LocationParseError
12-from .packages.urllib3.exceptions import TimeoutError
13-from .packages.urllib3.exceptions import SSLError as _SSLError
14-from .packages.urllib3.exceptions import HTTPError as _HTTPError
15-from .packages.urllib3 import connectionpool, poolmanager
16-from .packages.urllib3.filepost import encode_multipart_formdata
17+from urllib3.exceptions import MaxRetryError, LocationParseError
18+from urllib3.exceptions import TimeoutError
19+from urllib3.exceptions import SSLError as _SSLError
20+from urllib3.exceptions import HTTPError as _HTTPError
21+from urllib3 import connectionpool, poolmanager
22+from urllib3.filepost import encode_multipart_formdata
23 from .defaults import SCHEMAS
24 from .exceptions import (
25 ConnectionError, HTTPError, RequestException, Timeout, TooManyRedirects,
26--- a/requests/sessions.py
27+++ b/requests/sessions.py
28@@ -16,7 +16,7 @@
29 from .models import Request
30 from .hooks import dispatch_hook
31 from .utils import header_expand, from_key_val_list
32-from .packages.urllib3.poolmanager import PoolManager
33+from urllib3.poolmanager import PoolManager
34
35
36 def merge_kwargs(local_kwarg, default_kwarg):
37--- a/setup.py
38+++ b/setup.py
39@@ -20,24 +20,9 @@
40 packages = [
41 'requests',
42 'requests.packages',
43- 'requests.packages.urllib3',
44- 'requests.packages.urllib3.packages',
45- 'requests.packages.urllib3.packages.ssl_match_hostname'
46 ]
47
48-if is_py2:
49- packages.extend([
50- 'requests.packages.oauthlib',
51- 'requests.packages.oauthlib.oauth1',
52- 'requests.packages.oauthlib.oauth1.rfc5849',
53- 'requests.packages.oauthlib.oauth2',
54- 'requests.packages.oauthlib.oauth2.draft25',
55- 'requests.packages.chardet',
56- ])
57-else:
58- packages.append('requests.packages.chardet2')
59-
60-requires = []
61+requires = ['python-urllib3']
62
63 setup(
64 name='requests',
65--- a/requests/adapters.py
66+++ b/requests/adapters.py
67@@ -8,7 +8,7 @@
68 and maintain connections.
69 """
70
71-from .packages.urllib3.poolmanager import PoolManager
72+from urllib3.poolmanager import PoolManager
73
74 class BaseAdapter(object):
75 """The Base Transport Adapter"""
76--- a/requests/compat.py
77+++ b/requests/compat.py
78@@ -92,8 +92,20 @@
79 try:
80 import cchardet as chardet
81 except ImportError:
82- from .packages import chardet
83- from .packages.urllib3.packages.ordered_dict import OrderedDict
84+ import chardet
85+ # Here's the problem. Generally we want to use the system's urllib3
86+ # library instead of the embedded one. setup.py imports requests.compat
87+ # to get the is_py2 variable. However, if you're building the source
88+ # package on a system with an older urllib3 that doesn't have the
89+ # following import, setup.py will fail, and thus you cannot build the
90+ # source package. In that case (and hopefully in no others, since the
91+ # binary package Depends on python*-urllib3) grab the one from the
92+ # embedded package.
93+ try:
94+ from urllib3.packages.ordered_dict import OrderedDict
95+ except ImportError:
96+ from .packages.urllib3.packages.ordered_dict import OrderedDict
97+
98
99 builtin_str = str
100 bytes = str
101@@ -109,7 +121,7 @@
102 from http import cookiejar as cookielib
103 from http.cookies import Morsel
104 from io import StringIO
105- from .packages import chardet2 as chardet
106+ import chardet
107 from collections import OrderedDict
108
109 builtin_str = str
110--- a/requests/packages/__init__.py
111+++ b/requests/packages/__init__.py
112@@ -1,3 +1,3 @@
113 from __future__ import absolute_import
114
115-from . import urllib3
116+import urllib3
117--- a/requests/safe_mode.py
118+++ b/requests/safe_mode.py
119@@ -12,7 +12,7 @@
120 """
121
122 from .models import Response
123-from .packages.urllib3.response import HTTPResponse
124+from urllib3.response import HTTPResponse
125 from .exceptions import RequestException, ConnectionError, HTTPError
126 import socket
127
0128
=== added file 'debian/patches/series'
--- debian/patches/series 1970-01-01 00:00:00 +0000
+++ debian/patches/series 2013-01-28 21:17:21 +0000
@@ -0,0 +1,2 @@
102_do-not-use-embedded-python-six.patch
203-use-distro-packages.patch
03
=== modified file 'debian/rules'
--- debian/rules 2011-06-06 02:11:15 +0000
+++ debian/rules 2013-01-28 21:17:21 +0000
@@ -1,7 +1,29 @@
1#!/usr/bin/make -f1#!/usr/bin/make -f
22
3PYVERS := $(shell pyversions -r)
4
3%:5%:
4 dh $@ --with python2 --buildsystem=python_distutils6 dh $@ --with python2 --buildsystem=python_distutils
57
8override_dh_auto_build:
9 set -ex; \
10 for python in $(PYVERS); do \
11 $$python setup.py build; \
12 done
13
14override_dh_auto_clean:
15 rm -rf build
16 dh_auto_clean
17
18override_dh_auto_configure:
19 rm -rf requests/packages/urllib3
20
21override_dh_auto_install:
22 set -ex; \
23 for python in $(PYVERS); do \
24 $$python setup.py install --skip-build --root debian/python-requests \
25 --install-layout deb; \
26 done
27
6override_dh_installchangelogs:28override_dh_installchangelogs:
7 dh_installchangelogs HISTORY.rst upstream29 dh_installchangelogs HISTORY.rst
830
=== modified file 'requests.egg-info/PKG-INFO'
--- requests.egg-info/PKG-INFO 2011-11-25 00:02:28 +0000
+++ requests.egg-info/PKG-INFO 2013-01-28 21:17:21 +0000
@@ -1,14 +1,30 @@
1Metadata-Version: 1.01Metadata-Version: 1.1
2Name: requests2Name: requests
3Version: 0.8.23Version: 0.14.2
4Summary: Python HTTP for Humans.4Summary: Python HTTP for Humans.
5Home-page: http://python-requests.org5Home-page: http://python-requests.org
6Author: Kenneth Reitz6Author: Kenneth Reitz
7Author-email: me@kennethreitz.com7Author-email: me@kennethreitz.com
8License: ISC8License: Copyright (c) 2012 Kenneth Reitz.
9
10Permission to use, copy, modify, and/or distribute this software for any
11purpose with or without fee is hereby granted, provided that the above
12copyright notice and this permission notice appear in all copies.
13
14THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9Description: Requests: HTTP for Humans21Description: Requests: HTTP for Humans
10 =========================22 =========================
11 23
24
25 .. image:: https://secure.travis-ci.org/kennethreitz/requests.png?branch=develop
26 :target: https://secure.travis-ci.org/kennethreitz/requests
27
12 Requests is an ISC Licensed HTTP library, written in Python, for human28 Requests is an ISC Licensed HTTP library, written in Python, for human
13 beings.29 beings.
14 30
@@ -27,60 +43,32 @@
27 20443 204
28 >>> r.headers['content-type']44 >>> r.headers['content-type']
29 'application/json'45 'application/json'
30 >>> r.content46 >>> r.text
31 ...47 ...
32 48
33 See `the same code, without Requests <https://gist.github.com/973705>`_.49 See `the same code, without Requests <https://gist.github.com/973705>`_.
34 50
35 Requests allow you to send **HEAD**, **GET**, **POST**, **PUT**,51 Requests allow you to send HTTP/1.1 requests. You can add headers, form data,
36 **PATCH**, and **DELETE** HTTP requests. You can add headers, form data,
37 multipart files, and parameters with simple Python dictionaries, and access the52 multipart files, and parameters with simple Python dictionaries, and access the
38 response data in the same way. It's powered by httplib, but it does53 response data in the same way. It's powered by httplib and `urllib3
39 all the hard work and crazy hacks for you.54 <https://github.com/shazow/urllib3>`_, but it does all the hard work and crazy
55 hacks for you.
40 56
41 57
42 Features58 Features
43 --------59 --------
44 60
45 - Extremely simple HEAD, GET, POST, PUT, PATCH, DELETE Requests.61 - International Domains and URLs
46 - Gevent support for Asyncronous Requests.62 - Keep-Alive & Connection Pooling
47 - Sessions with cookie persistience.63 - Sessions with Cookie Persistence
48 - Basic, Digest, and Custom Authentication support.64 - Browser-style SSL Verification
49 - Automatic form-encoding of dictionaries65 - Basic/Digest Authentication
50 - A simple dictionary interface for request/response cookies.66 - Elegant Key/Value Cookies
51 - Multipart file uploads.67 - Automatic Decompression
52 - Automatc decoding of Unicode, gzip, and deflate responses.68 - Unicode Response Bodies
53 - Full support for unicode URLs and domain names.69 - Multipart File Uploads
54 70 - Connection Timeouts
55 71 - Thread-safety
56 Usage
57 -----
58
59 It couldn't be simpler. ::
60
61 >>> import requests
62 >>> r = requests.get('http://google.com')
63
64
65 HTTPS? Basic Authentication? ::
66
67 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass')
68 >>> r.status_code
69 401
70
71
72 Uh oh, we're not authorized! Let's add authentication. ::
73
74 >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass'))
75
76 >>> r.status_code
77 200
78
79 >>> r.headers['content-type']
80 'application/json'
81
82 >>> r.content
83 '{"authenticated": true, "user": "user"}'
84 72
85 73
86 Installation74 Installation
@@ -107,16 +95,312 @@
107 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.95 #. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS_.
108 96
109 .. _`the repository`: http://github.com/kennethreitz/requests97 .. _`the repository`: http://github.com/kennethreitz/requests
110 .. _AUTHORS: http://github.com/kennethreitz/requests/blob/master/AUTHORS98 .. _AUTHORS: https://github.com/kennethreitz/requests/blob/develop/AUTHORS.rst
111 99
100
101 .. :changelog:
112 102
113 History103 History
114 -------104 -------
115 105
106 0.14.2 (2012-10-27)
107 +++++++++++++++++++
108
109 - Improved mime-compatible JSON handling
110 - Proxy fixes
111 - Path hack fixes
112 - Case-Insensistive Content-Encoding headers
113 - Support for CJK parameters in form posts
114
115
116 0.14.1 (2012-10-01)
117 +++++++++++++++++++
118
119 - Python 3.3 Compatibility
120 - Simply default accept-encoding
121 - Bugfixes
122
123
124 0.14.0 (2012-09-02)
125 ++++++++++++++++++++
126
127 - No more iter_content errors if already downloaded.
128
129 0.13.9 (2012-08-25)
130 +++++++++++++++++++
131
132 - Fix for OAuth + POSTs
133 - Remove exception eating from dispatch_hook
134 - General bugfixes
135
136 0.13.8 (2012-08-21)
137 +++++++++++++++++++
138
139 - Incredible Link header support :)
140
141 0.13.7 (2012-08-19)
142 +++++++++++++++++++
143
144 - Support for (key, value) lists everywhere.
145 - Digest Authentication improvements.
146 - Ensure proxy exclusions work properly.
147 - Clearer UnicodeError exceptions.
148 - Automatic casting of URLs to tsrings (fURL and such)
149 - Bugfixes.
150
151 0.13.6 (2012-08-06)
152 +++++++++++++++++++
153
154 - Long awaited fix for hanging connections!
155
156 0.13.5 (2012-07-27)
157 +++++++++++++++++++
158
159 - Packaging fix
160
161 0.13.4 (2012-07-27)
162 +++++++++++++++++++
163
164 - GSSAPI/Kerberos authentication!
165 - App Engine 2.7 Fixes!
166 - Fix leaking connections (from urllib3 update)
167 - OAuthlib path hack fix
168 - OAuthlib URL parameters fix.
169
170 0.13.3 (2012-07-12)
171 +++++++++++++++++++
172
173 - Use simplejson if available.
174 - Do not hide SSLErrors behind Timeouts.
175 - Fixed param handling with urls containing fragments.
176 - Significantly improved information in User Agent.
177 - client certificates are ignored when verify=False
178
179 0.13.2 (2012-06-28)
180 +++++++++++++++++++
181
182 - Zero dependencies (once again)!
183 - New: Response.reason
184 - Sign querystring parameters in OAuth 1.0
185 - Client certificates no longer ignored when verify=False
186 - Add openSUSE certificate support
187
188 0.13.1 (2012-06-07)
189 +++++++++++++++++++
190
191 - Allow passing a file or file-like object as data.
192 - Allow hooks to return responses that indicate errors.
193 - Fix Response.text and Response.json for body-less responses.
194
195 0.13.0 (2012-05-29)
196 +++++++++++++++++++
197
198 - Removal of Requests.async in favor of `grequests <https://github.com/kennethreitz/grequests>`_
199 - Allow disabling of cookie persistiance.
200 - New implimentation of safe_mode
201 - cookies.get now supports default argument
202 - Session cookies not saved when Session.request is called with return_response=False
203 - Env: no_proxy support.
204 - RequestsCookieJar improvements.
205 - Various bug fixes.
206
207 0.12.1 (2012-05-08)
208 +++++++++++++++++++
209
210 - New ``Response.json`` property.
211 - Ability to add string file uploads.
212 - Fix out-of-range issue with iter_lines.
213 - Fix iter_content default size.
214 - Fix POST redirects containing files.
215
216 0.12.0 (2012-05-02)
217 +++++++++++++++++++
218
219 - EXPERIMENTAL OAUTH SUPPORT!
220 - Proper CookieJar-backed cookies interface with awesome dict-like interface.
221 - Speed fix for non-iterated content chunks.
222 - Move ``pre_request`` to a more usable place.
223 - New ``pre_send`` hook.
224 - Lazily encode data, params, files.
225 - Load system Certificate Bundle if ``certify`` isn't available.
226 - Cleanups, fixes.
227
228 0.11.2 (2012-04-22)
229 +++++++++++++++++++
230
231 - Attempt to use the OS's certificate bundle if ``certifi`` isn't available.
232 - Infinite digest auth redirect fix.
233 - Multi-part file upload improvements.
234 - Fix decoding of invalid %encodings in URLs.
235 - If there is no content in a response don't throw an error the second time that content is attempted to be read.
236 - Upload data on redirects.
237
238 0.11.1 (2012-03-30)
239 +++++++++++++++++++
240
241 * POST redirects now break RFC to do what browsers do: Follow up with a GET.
242 * New ``strict_mode`` configuration to disable new redirect behavior.
243
244
245 0.11.0 (2012-03-14)
246 +++++++++++++++++++
247
248 * Private SSL Certificate support
249 * Remove select.poll from Gevent monkeypatching
250 * Remove redundant generator for chunked transfer encoding
251 * Fix: Response.ok raises Timeout Exception in safe_mode
252
253 0.10.8 (2012-03-09)
254 +++++++++++++++++++
255
256 * Generate chunked ValueError fix
257 * Proxy configuration by environment variables
258 * Simplification of iter_lines.
259 * New `trust_env` configuration for disabling system/environment hints.
260 * Suppress cookie errors.
261
262 0.10.7 (2012-03-07)
263 +++++++++++++++++++
264
265 * `encode_uri` = False
266
267 0.10.6 (2012-02-25)
268 +++++++++++++++++++
269
270 * Allow '=' in cookies.
271
272 0.10.5 (2012-02-25)
273 +++++++++++++++++++
274
275 * Response body with 0 content-length fix.
276 * New async.imap.
277 * Don't fail on netrc.
278
279
280 0.10.4 (2012-02-20)
281 +++++++++++++++++++
282
283 * Honor netrc.
284
285 0.10.3 (2012-02-20)
286 +++++++++++++++++++
287
288 * HEAD requests don't follow redirects anymore.
289 * raise_for_status() doesn't raise for 3xx anymore.
290 * Make Session objects picklable.
291 * ValueError for invalid schema URLs.
292
293 0.10.2 (2012-01-15)
294 +++++++++++++++++++
295
296 * Vastly improved URL quoting.
297 * Additional allowed cookie key values.
298 * Attempted fix for "Too many open files" Error
299 * Replace unicode errors on first pass, no need for second pass.
300 * Append '/' to bare-domain urls before query insertion.
301 * Exceptions now inherit from RuntimeError.
302 * Binary uploads + auth fix.
303 * Bugfixes.
304
305
306 0.10.1 (2012-01-23)
307 +++++++++++++++++++
308
309 * PYTHON 3 SUPPORT!
310 * Dropped 2.5 Support. (*Backwards Incompatible*)
311
312 0.10.0 (2012-01-21)
313 +++++++++++++++++++
314
315 * ``Response.content`` is now bytes-only. (*Backwards Incompatible*)
316 * New ``Response.text`` is unicode-only.
317 * If no ``Response.encoding`` is specified and ``chardet`` is available, ``Respoonse.text`` will guess an encoding.
318 * Default to ISO-8859-1 (Western) encoding for "text" subtypes.
319 * Removal of `decode_unicode`. (*Backwards Incompatible*)
320 * New multiple-hooks system.
321 * New ``Response.register_hook`` for registering hooks within the pipeline.
322 * ``Response.url`` is now Unicode.
323
324 0.9.3 (2012-01-18)
325 ++++++++++++++++++
326
327 * SSL verify=False bugfix (apparent on windows machines).
328
329 0.9.2 (2012-01-18)
330 ++++++++++++++++++
331
332 * Asynchronous async.send method.
333 * Support for proper chunk streams with boundaries.
334 * session argument for Session classes.
335 * Print entire hook tracebacks, not just exception instance.
336 * Fix response.iter_lines from pending next line.
337 * Fix but in HTTP-digest auth w/ URI having query strings.
338 * Fix in Event Hooks section.
339 * Urllib3 update.
340
341
342 0.9.1 (2012-01-06)
343 ++++++++++++++++++
344
345 * danger_mode for automatic Response.raise_for_status()
346 * Response.iter_lines refactor
347
348 0.9.0 (2011-12-28)
349 ++++++++++++++++++
350
351 * verify ssl is default.
352
353
354 0.8.9 (2011-12-28)
355 ++++++++++++++++++
356
357 * Packaging fix.
358
359
360 0.8.8 (2011-12-28)
361 ++++++++++++++++++
362
363 * SSL CERT VERIFICATION!
364 * Release of Cerifi: Mozilla's cert list.
365 * New 'verify' argument for SSL requests.
366 * Urllib3 update.
367
368 0.8.7 (2011-12-24)
369 ++++++++++++++++++
370
371 * iter_lines last-line truncation fix
372 * Force safe_mode for async requests
373 * Handle safe_mode exceptions more consistently
374 * Fix iteration on null responses in safe_mode
375
376 0.8.6 (2011-12-18)
377 ++++++++++++++++++
378
379 * Socket timeout fixes.
380 * Proxy Authorization support.
381
382 0.8.5 (2011-12-14)
383 ++++++++++++++++++
384
385 * Response.iter_lines!
386
387 0.8.4 (2011-12-11)
388 ++++++++++++++++++
389
390 * Prefetch bugfix.
391 * Added license to installed version.
392
393 0.8.3 (2011-11-27)
394 ++++++++++++++++++
395
396 * Converted auth system to use simpler callable objects.
397 * New session parameter to API methods.
398 * Display full URL while logging.
399
116 0.8.2 (2011-11-19)400 0.8.2 (2011-11-19)
117 ++++++++++++++++++401 ++++++++++++++++++
118 402
119 * New unicode decoding system, based on overridable `Response.encoding`.403 * New Unicode decoding system, based on over-ridable `Response.encoding`.
120 * Proper URL slash-quote handling.404 * Proper URL slash-quote handling.
121 * Cookies with ``[``, ``]``, and ``_`` allowed.405 * Cookies with ``[``, ``]``, and ``_`` allowed.
122 406
@@ -140,6 +424,7 @@
140 * OPTION method424 * OPTION method
141 * Async pool size throttling425 * Async pool size throttling
142 * File uploads send real names426 * File uploads send real names
427 * Vendored in urllib3
143 428
144 0.7.6 (2011-11-07)429 0.7.6 (2011-11-07)
145 ++++++++++++++++++430 ++++++++++++++++++
@@ -155,7 +440,7 @@
155 0.7.4 (2011-10-26)440 0.7.4 (2011-10-26)
156 ++++++++++++++++++441 ++++++++++++++++++
157 442
158 * Sesion Hooks fix.443 * Session Hooks fix.
159 444
160 0.7.3 (2011-10-23)445 0.7.3 (2011-10-23)
161 ++++++++++++++++++446 ++++++++++++++++++
@@ -386,6 +671,10 @@
386Classifier: Natural Language :: English671Classifier: Natural Language :: English
387Classifier: License :: OSI Approved :: ISC License (ISCL)672Classifier: License :: OSI Approved :: ISC License (ISCL)
388Classifier: Programming Language :: Python673Classifier: Programming Language :: Python
389Classifier: Programming Language :: Python :: 2.5
390Classifier: Programming Language :: Python :: 2.6674Classifier: Programming Language :: Python :: 2.6
391Classifier: Programming Language :: Python :: 2.7675Classifier: Programming Language :: Python :: 2.7
676Classifier: Programming Language :: Python :: 3
677Classifier: Programming Language :: Python :: 3.0
678Classifier: Programming Language :: Python :: 3.1
679Classifier: Programming Language :: Python :: 3.2
680Classifier: Programming Language :: Python :: 3.3
392681
=== modified file 'requests.egg-info/SOURCES.txt'
--- requests.egg-info/SOURCES.txt 2011-11-25 00:02:28 +0000
+++ requests.egg-info/SOURCES.txt 2013-01-28 21:17:21 +0000
@@ -1,17 +1,24 @@
1HISTORY.rst1HISTORY.rst
2LICENSE2LICENSE
3MANIFEST.in3MANIFEST.in
4NOTICE
4README.rst5README.rst
5setup.py6setup.py
6test_requests.py
7requests/__init__.py7requests/__init__.py
8requests/_oauth.py
9requests/adapters.py
8requests/api.py10requests/api.py
9requests/async.py11requests/async.py
10requests/auth.py12requests/auth.py
13requests/cacert.pem
14requests/certs.py
15requests/compat.py
16requests/cookies.py
11requests/defaults.py17requests/defaults.py
12requests/exceptions.py18requests/exceptions.py
13requests/hooks.py19requests/hooks.py
14requests/models.py20requests/models.py
21requests/safe_mode.py
15requests/sessions.py22requests/sessions.py
16requests/status_codes.py23requests/status_codes.py
17requests/structures.py24requests/structures.py
@@ -21,10 +28,53 @@
21requests.egg-info/dependency_links.txt28requests.egg-info/dependency_links.txt
22requests.egg-info/top_level.txt29requests.egg-info/top_level.txt
23requests/packages/__init__.py30requests/packages/__init__.py
24requests/packages/oreos/__init__.py31requests/packages/chardet/__init__.py
25requests/packages/oreos/core.py32requests/packages/chardet/big5freq.py
26requests/packages/oreos/monkeys.py33requests/packages/chardet/big5prober.py
27requests/packages/oreos/structures.py34requests/packages/chardet/chardistribution.py
35requests/packages/chardet/charsetgroupprober.py
36requests/packages/chardet/charsetprober.py
37requests/packages/chardet/codingstatemachine.py
38requests/packages/chardet/constants.py
39requests/packages/chardet/escprober.py
40requests/packages/chardet/escsm.py
41requests/packages/chardet/eucjpprober.py
42requests/packages/chardet/euckrfreq.py
43requests/packages/chardet/euckrprober.py
44requests/packages/chardet/euctwfreq.py
45requests/packages/chardet/euctwprober.py
46requests/packages/chardet/gb2312freq.py
47requests/packages/chardet/gb2312prober.py
48requests/packages/chardet/hebrewprober.py
49requests/packages/chardet/jisfreq.py
50requests/packages/chardet/jpcntx.py
51requests/packages/chardet/langbulgarianmodel.py
52requests/packages/chardet/langcyrillicmodel.py
53requests/packages/chardet/langgreekmodel.py
54requests/packages/chardet/langhebrewmodel.py
55requests/packages/chardet/langhungarianmodel.py
56requests/packages/chardet/langthaimodel.py
57requests/packages/chardet/latin1prober.py
58requests/packages/chardet/mbcharsetprober.py
59requests/packages/chardet/mbcsgroupprober.py
60requests/packages/chardet/mbcssm.py
61requests/packages/chardet/sbcharsetprober.py
62requests/packages/chardet/sbcsgroupprober.py
63requests/packages/chardet/sjisprober.py
64requests/packages/chardet/universaldetector.py
65requests/packages/chardet/utf8prober.py
66requests/packages/oauthlib/__init__.py
67requests/packages/oauthlib/common.py
68requests/packages/oauthlib/oauth1/__init__.py
69requests/packages/oauthlib/oauth1/rfc5849/__init__.py
70requests/packages/oauthlib/oauth1/rfc5849/parameters.py
71requests/packages/oauthlib/oauth1/rfc5849/signature.py
72requests/packages/oauthlib/oauth1/rfc5849/utils.py
73requests/packages/oauthlib/oauth2/__init__.py
74requests/packages/oauthlib/oauth2/draft25/__init__.py
75requests/packages/oauthlib/oauth2/draft25/parameters.py
76requests/packages/oauthlib/oauth2/draft25/tokens.py
77requests/packages/oauthlib/oauth2/draft25/utils.py
28requests/packages/urllib3/__init__.py78requests/packages/urllib3/__init__.py
29requests/packages/urllib3/_collections.py79requests/packages/urllib3/_collections.py
30requests/packages/urllib3/connectionpool.py80requests/packages/urllib3/connectionpool.py
@@ -32,4 +82,9 @@
32requests/packages/urllib3/filepost.py82requests/packages/urllib3/filepost.py
33requests/packages/urllib3/poolmanager.py83requests/packages/urllib3/poolmanager.py
34requests/packages/urllib3/request.py84requests/packages/urllib3/request.py
35requests/packages/urllib3/response.py
36\ No newline at end of file85\ No newline at end of file
86requests/packages/urllib3/response.py
87requests/packages/urllib3/util.py
88requests/packages/urllib3/packages/__init__.py
89requests/packages/urllib3/packages/ordered_dict.py
90requests/packages/urllib3/packages/six.py
91requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
37\ No newline at end of file92\ No newline at end of file
3893
=== modified file 'requests/__init__.py'
--- requests/__init__.py 2011-11-25 00:02:28 +0000
+++ requests/__init__.py 2013-01-28 21:17:21 +0000
@@ -6,20 +6,47 @@
6# /6# /
77
8"""8"""
9requests9requests HTTP library
10~~~~~~~~10~~~~~~~~~~~~~~~~~~~~~
1111
12:copyright: (c) 2011 by Kenneth Reitz.12Requests is an HTTP library, written in Python, for human beings. Basic GET
13usage:
14
15 >>> import requests
16 >>> r = requests.get('http://python.org')
17 >>> r.status_code
18 200
19 >>> 'Python is a programming language' in r.content
20 True
21
22... or POST:
23
24 >>> payload = dict(key1='value1', key2='value2')
25 >>> r = requests.post("http://httpbin.org/post", data=payload)
26 >>> print r.text
27 {
28 ...
29 "form": {
30 "key2": "value2",
31 "key1": "value1"
32 },
33 ...
34 }
35
36The other HTTP methods are supported - see `requests.api`. Full documentation
37is at <http://python-requests.org>.
38
39:copyright: (c) 2012 by Kenneth Reitz.
13:license: ISC, see LICENSE for more details.40:license: ISC, see LICENSE for more details.
1441
15"""42"""
1643
17__title__ = 'requests'44__title__ = 'requests'
18__version__ = '0.8.2'45__version__ = '0.14.2'
19__build__ = 0x00080246__build__ = 0x001402
20__author__ = 'Kenneth Reitz'47__author__ = 'Kenneth Reitz'
21__license__ = 'ISC'48__license__ = 'ISC'
22__copyright__ = 'Copyright 2011 Kenneth Reitz'49__copyright__ = 'Copyright 2012 Kenneth Reitz'
2350
2451
25from . import utils52from . import utils
2653
=== added file 'requests/_oauth.py'
--- requests/_oauth.py 1970-01-01 00:00:00 +0000
+++ requests/_oauth.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,23 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests._oauth
5~~~~~~~~~~~~~~~
6
7This module contains the path hack necessary for oauthlib to be vendored into
8requests while allowing upstream changes.
9"""
10
11import os
12import sys
13
14try:
15 from oauthlib.oauth1 import rfc5849
16 from oauthlib.common import extract_params
17 from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER)
18except ImportError:
19 from .packages import oauthlib
20 sys.modules['oauthlib'] = oauthlib
21 from oauthlib.oauth1 import rfc5849
22 from oauthlib.common import extract_params
23 from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER)
024
=== added file 'requests/adapters.py'
--- requests/adapters.py 1970-01-01 00:00:00 +0000
+++ requests/adapters.py 2013-01-28 21:17:21 +0000
@@ -0,0 +1,58 @@
1# -*- coding: utf-8 -*-
2
3"""
4requests.adapters
5~~~~~~~~~~~~~~~~~
6
7This module contains the transport adapters that Requests uses to define
8and maintain connections.
9"""
10
11from urllib3.poolmanager import PoolManager
12
13class BaseAdapter(object):
14 """The Base Transport Adapter"""
15
16 def __init__(self, config=None):
17 super(BaseAdapter, self).__init__()
18 self.config = config or {}
19 self.session = None
20
21 @property
22 def configure(self, config):
23 self.config.update(config)
24
25 def send(self):
26 raise NotImplementedError
27
28 def close(self):
29 raise NotImplementedError
30
31
32class HTTPAdapter(BaseAdapter):
33 """Built-In HTTP Adapter for Urllib3."""
34 def __init__(self):
35 super(HTTPAdapter, self).__init__()
36
37 self.init_poolmanager()
38
39 def init_poolmanager(self):
40 self.poolmanager = PoolManager(
41 num_pools=self.config.get('pool_connections'),
42 maxsize=self.config.get('pool_maxsize')
43 )
44
45 def close(self):
46 """Dispose of any internal state.
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: