From d91af4cadfa5fa299d4702a9eedbfc7f7f558b9d Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Thu, 26 May 2011 15:37:31 -0400 Subject: [PATCH 01/23] add debian packaging --- debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 13 +++++++++++++ debian/docs | 1 + debian/pyversions | 1 + debian/rules | 42 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/docs create mode 100644 debian/pyversions create mode 100755 debian/rules diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..519752c4 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +python-requests (0.4.1-0) testing; urgency=low + + * Initial Debian package + + -- Bruno Clermont Thu, 26 May 2011 16:25:00 -0500 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..7ed6ff82 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..5c6ce49a --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: python-requests +Section: python +Priority: optional +Maintainer: Bruno Clermont +Homepage: https://github.com/bclermont/requests +Bugs: https://github.com/bclermont/requests/issues +Build-Depends: debhelper, python-support + +Package: python-requests +Architecture: all +Depends: ${python:Depends}, python-support +Provides: ${python:Provides} +Description: Python HTTP Requests for Humans. diff --git a/debian/docs b/debian/docs new file mode 100644 index 00000000..9bb74d2d --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +docs/user/*.rst \ No newline at end of file diff --git a/debian/pyversions b/debian/pyversions new file mode 100644 index 00000000..8b253bc3 --- /dev/null +++ b/debian/pyversions @@ -0,0 +1 @@ +2.4- diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..28e92ec0 --- /dev/null +++ b/debian/rules @@ -0,0 +1,42 @@ +#!/usr/bin/make -f + +# Verbose mode +#export DH_VERBOSE=1 + +clean: + dh_testdir + dh_testroot + + rm -rf build requests.egg-info +# find django-sentry/ -name *.pyc | xargs rm -f + + dh_clean + +build: + dh_testdir + + python setup.py build + +install: + dh_testdir + dh_installdirs + + python setup.py install --root $(CURDIR)/debian/python-requests + +binary-indep: install + +binary-arch: install + dh_install + dh_installdocs +# dh_installchangelogs + dh_compress + dh_fixperms + dh_pysupport + dh_gencontrol + dh_installdeb + dh_md5sums + dh_builddeb -- -Z lzma -z9 + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary + From 73b414ab4564486f2335f02a1727fd0f4d005608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rube=CC=81n=20Abad?= Date: Wed, 13 Jul 2011 11:08:54 +0200 Subject: [PATCH 02/23] We can represent multivalued params with arrays --- requests/models.py | 13 +++++++------ test_requests.py | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/requests/models.py b/requests/models.py index a67691dd..a8335d1d 100644 --- a/requests/models.py +++ b/requests/models.py @@ -211,18 +211,19 @@ class Request(object): """Encode parameters in a piece of data. If the data supplied is a dictionary, encodes each parameter in it, and - returns the dictionary of encoded parameters, and a urlencoded version - of that. + returns a list of tuples containing the encoded parameters, and a urlencoded + version of that. Otherwise, assumes the data is already encoded appropriately, and returns it twice. """ if hasattr(data, 'items'): - result = {} - for (k, v) in data.items(): - result[k.encode('utf-8') if isinstance(k, unicode) else k] \ - = v.encode('utf-8') if isinstance(v, unicode) else v + result = [] + for k, vs in data.items(): + for v in isinstance(vs, list) and vs or [vs]: + result.append((k.encode('utf-8') if isinstance(k, unicode) else k, + v.encode('utf-8') if isinstance(v, unicode) else v)) return result, urllib.urlencode(result, doseq=True) else: return data, data diff --git a/test_requests.py b/test_requests.py index f2aded24..d4e50a6f 100755 --- a/test_requests.py +++ b/test_requests.py @@ -325,6 +325,30 @@ class RequestsTestSuite(unittest.TestCase): r = requests.get(u'http://➡.ws/httpbin') self.assertEqual(r.url, HTTPBIN_URL) + def test_urlencoded_get_query_multivalued_param(self): + r = requests.get(httpbin('get'), params=dict(test=['foo','baz'])) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.url, httpbin('get?test=foo&test=baz')) + + def test_urlencoded_post_querystring_multivalued(self): + r = requests.post(httpbin('post'), params=dict(test=['foo','baz'])) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.headers['content-type'], 'application/json') + self.assertEquals(r.url, httpbin('post?test=foo&test=baz')) + rbody = json.loads(r.content) + self.assertEquals(rbody.get('form'), {}) # No form supplied + self.assertEquals(rbody.get('data'), '') + + def test_urlencoded_post_query_multivalued_and_data(self): + r = requests.post(httpbin('post'), params=dict(test=['foo','baz']), + data=dict(test2="foobar",test3=['foo','baz'])) + self.assertEquals(r.status_code, 200) + self.assertEquals(r.headers['content-type'], 'application/json') + self.assertEquals(r.url, httpbin('post?test=foo&test=baz')) + rbody = json.loads(r.content) + self.assertEquals(rbody.get('form'), dict(test2='foobar',test3='foo')) + self.assertEquals(rbody.get('data'), '') + if __name__ == '__main__': unittest.main() From f408829d516614c813a59621bfec9b09a6251da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gul=C3=A1csi=20Tam=C3=A1s?= Date: Sat, 23 Jul 2011 22:15:28 +0200 Subject: [PATCH 03/23] test_request: simplejson is just as good as omnijson for test --- test_requests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_requests.py b/test_requests.py index f2aded24..c3f3395d 100755 --- a/test_requests.py +++ b/test_requests.py @@ -6,7 +6,10 @@ from __future__ import with_statement import unittest import cookielib -import omnijson as json +try: + import omnijson as json +except ImportError: + import simplejson as json import requests From 04c456b8775a2560d0fffad445745793929a82f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gul=C3=A1csi=20Tam=C3=A1s?= Date: Sat, 23 Jul 2011 22:16:12 +0200 Subject: [PATCH 04/23] structures: little bit more general, lower-key-caching version of CaseInsensitiveDict --- requests/structures.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/requests/structures.py b/requests/structures.py index bfee7b19..b23b72b0 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -9,20 +9,39 @@ Datastructures that power Requests. """ class CaseInsensitiveDict(dict): - """Case-insensitive Dictionary for :class:`Response ` Headers. + """Case-insensitive Dictionary For example, ``headers['content-encoding']`` will return the value of a ``'Content-Encoding'`` response header.""" - def _lower_keys(self): - return map(str.lower, self.keys()) + @property + def lower_keys(self): + if not hasattr(self, '_lower_keys') or not self._lower_keys: + self._lower_keys = dict((k.lower(), k) for k in self.iterkeys()) + return self._lower_keys + def _clear_lower_keys(self): + if hasattr(self, '_lower_keys'): + self._lower_keys.clear() + + def __setitem__(self, key, value): + dict.__setitem__(self, key, value) + self._clear_lower_keys() + + def __delitem__(self, key): + dict.__delitem__(self, key, value) + self._lower_keys.clear() def __contains__(self, key): - return key.lower() in self._lower_keys() - + return key.lower() in self.lower_keys def __getitem__(self, key): # We allow fall-through here, so values default to None if key in self: - return self.items()[self._lower_keys().index(key.lower())][1] + return dict.__getitem__(self, self.lower_keys[key.lower()]) + + def get(self, key, default=None): + if key in self: + return self[key] + else: + return default From 369e7cb38f7cd2b5ccbc86127d3a59f2fb8790c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gul=C3=A1csi=20Tam=C3=A1s?= Date: Sat, 23 Jul 2011 22:19:28 +0200 Subject: [PATCH 05/23] add myself to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 1f7c743f..fd536448 100644 --- a/AUTHORS +++ b/AUTHORS @@ -28,3 +28,4 @@ Patches and Suggestions - Alberto Paro - Jérémy Bethmont - 潘旭 (Xu Pan) +- Tamás Gulácsi From 747f882b0e99f7d70e08acef78e517df93085c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gul=C3=A1csi=20Tam=C3=A1s?= Date: Sat, 23 Jul 2011 22:25:07 +0200 Subject: [PATCH 06/23] structures: CaseInsensitiveDict.__delitem__ missing "value" fix --- requests/structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/structures.py b/requests/structures.py index b23b72b0..dd5168cf 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -29,7 +29,7 @@ class CaseInsensitiveDict(dict): self._clear_lower_keys() def __delitem__(self, key): - dict.__delitem__(self, key, value) + dict.__delitem__(self, key) self._lower_keys.clear() def __contains__(self, key): From 7d91d3fb5c8c826f4972db36c27384fc0e6550b9 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 20:10:37 -0400 Subject: [PATCH 07/23] use patched HTTPBasicAuthHandler --- requests/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index a67691dd..575ec8b5 100644 --- a/requests/models.py +++ b/requests/models.py @@ -545,6 +545,6 @@ class AuthObject(object): self.realm = realm if isinstance(handler, basestring): - self.handler = self._handlers.get(handler.lower(), urllib2.HTTPBasicAuthHandler) + self.handler = self._handlers.get(handler.lower(), HTTPBasicAuthHandler) else: self.handler = handler From 30d699b64fbf298881c0de88cd6b727b1972538a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:36:24 -0400 Subject: [PATCH 08/23] Forced Basic Auth for 404'd resources --- requests/monkeys.py | 61 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/requests/monkeys.py b/requests/monkeys.py index 41cd3706..909626c5 100644 --- a/requests/monkeys.py +++ b/requests/monkeys.py @@ -9,7 +9,7 @@ Urllib2 Monkey patches. """ import urllib2 - +import re class Request(urllib2.Request): """Hidden wrapper around the urllib2.Request object. Allows for manual @@ -26,8 +26,9 @@ class Request(urllib2.Request): return urllib2.Request.get_method(self) -class HTTPRedirectHandler(urllib2.HTTPRedirectHandler): +class HTTPRedirectHandler(urllib2.HTTPRedirectHandler): + """HTTP Redirect handler.""" def http_error_301(self, req, fp, code, msg, headers): pass @@ -36,17 +37,20 @@ class HTTPRedirectHandler(urllib2.HTTPRedirectHandler): class HTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): + """HTTP Basic Auth Handler with authentication loop fixes.""" def __init__(self, *args, **kwargs): urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs) self.retried_req = None + def reset_retry_count(self): # Python 2.6.5 will call this on 401 or 407 errors and thus loop # forever. We disable reset_retry_count completely and reset in # http_error_auth_reqed instead. pass + def http_error_auth_reqed(self, auth_header, host, req, headers): # Reset the retry counter once for each request. if req is not self.retried_req: @@ -59,6 +63,59 @@ class HTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): +class HTTPForcedBasicAuthHandler(HTTPBasicAuthHandler): + """HTTP Basic Auth Handler with forced Authentication.""" + + auth_header = 'Authorization' + rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+' + 'realm=(["\'])(.*?)\\2', re.I) + + def __init__(self, *args, **kwargs): + HTTPBasicAuthHandler.__init__(self, *args, **kwargs) + + + def http_error_401(self, req, fp, code, msg, headers): + url = req.get_full_url() + response = self._http_error_auth_reqed('www-authenticate', url, req, headers) + self.reset_retry_count() + return response + + http_error_404 = http_error_401 + + + def _http_error_auth_reqed(self, authreq, host, req, headers): + + authreq = headers.get(authreq, None) + + if self.retried > 5: + # retry sending the username:password 5 times before failing. + raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed", + headers, None) + else: + self.retried += 1 + + if authreq: + + mo = self.rx.search(authreq) + + if mo: + scheme, quote, realm = mo.groups() + + if scheme.lower() == 'basic': + response = self.retry_http_basic_auth(host, req, realm) + + if response and response.code not in (401, 404): + self.retried = 0 + return response + else: + response = self.retry_http_basic_auth(host, req, 'Realm') + + if response and response.code not in (401, 404): + self.retried = 0 + return response + + + class HTTPDigestAuthHandler(urllib2.HTTPDigestAuthHandler): def __init__(self, *args, **kwargs): From 5fff2c757b7e95b22610a171e6eb07c2d12acdda Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:37:08 -0400 Subject: [PATCH 09/23] forced_basic default handler. --- requests/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/requests/models.py b/requests/models.py index 575ec8b5..289546c2 100644 --- a/requests/models.py +++ b/requests/models.py @@ -16,7 +16,7 @@ from urlparse import urlparse, urlunparse from datetime import datetime from .config import settings -from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler +from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler from .structures import CaseInsensitiveDict from .packages.poster.encode import multipart_encode from .packages.poster.streaminghttp import register_openers, get_handlers @@ -80,6 +80,11 @@ class Request(object): #: True if Request has been sent. self.sent = False + headers = settings.base_headers + if self.headers: + headers.update(self.headers) + self.headers = headers + def __repr__(self): return '' % (self.method) @@ -534,17 +539,18 @@ class AuthObject(object): _handlers = { 'basic': HTTPBasicAuthHandler, + 'forced_basic': HTTPForcedBasicAuthHandler, 'digest': HTTPDigestAuthHandler, 'proxy_basic': urllib2.ProxyBasicAuthHandler, 'proxy_digest': urllib2.ProxyDigestAuthHandler } - def __init__(self, username, password, handler='basic', realm=None): + def __init__(self, username, password, handler='forced_basic', realm=None): self.username = username self.password = password self.realm = realm if isinstance(handler, basestring): - self.handler = self._handlers.get(handler.lower(), HTTPBasicAuthHandler) + self.handler = self._handlers.get(handler.lower(), HTTPForcedBasicAuthHandler) else: self.handler = handler From 260e32a7c329c868ae59c045ef8521f6f9003778 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:39:14 -0400 Subject: [PATCH 10/23] default user agent! --- requests/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requests/config.py b/requests/config.py index 0878da92..c34a2b94 100644 --- a/requests/config.py +++ b/requests/config.py @@ -53,4 +53,5 @@ class Settings(object): return None return object.__getattribute__(self, key) -settings = Settings() \ No newline at end of file +settings = Settings() +settings.base_headers = {'User-Agent': 'python-requests.org'} \ No newline at end of file From 87e7a0420964558efb4c8e7904b0730331ee26d5 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:42:12 -0400 Subject: [PATCH 11/23] v0.5.1 history update --- HISTORY.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6b60210f..64bc4f8b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,10 +1,15 @@ History ------- -0.5.1 (?) -+++++++++ +0.5.1 (2011-07-23) +++++++++++++++++++ * International Domain Name Support! +* Access headers without fetching entire body (``read()``) +* Use lists as dicts for parameters +* Add Forced Basic Authentication +* Forced Basic is default authentication type +* ``python-requests.org`` default User-Agent header 0.5.0 (2011-06-21) From 2edda29448a9530059b9d6f772ba1e9a92371e7b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:48:28 -0400 Subject: [PATCH 12/23] fixing bad url shortner link --- test_requests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_requests.py b/test_requests.py index c3f3395d..f23aa071 100755 --- a/test_requests.py +++ b/test_requests.py @@ -9,7 +9,7 @@ import cookielib try: import omnijson as json except ImportError: - import simplejson as json + import json import requests @@ -326,7 +326,7 @@ class RequestsTestSuite(unittest.TestCase): def test_idna(self): r = requests.get(u'http://➡.ws/httpbin') - self.assertEqual(r.url, HTTPBIN_URL) + assert 'tinyarrows.com' in r.url if __name__ == '__main__': From 080db5ee5d8bfdd7106b1c555a72935da2b5bbc5 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 21:49:08 -0400 Subject: [PATCH 13/23] CaseInsensitiveDict notes --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 64bc4f8b..5bc0d659 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ History * Add Forced Basic Authentication * Forced Basic is default authentication type * ``python-requests.org`` default User-Agent header +* CaseInsensitiveDict lower-case caching 0.5.0 (2011-06-21) From 1e1fb1e7a81b0a925e772e20db24e4ef5c94ae72 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:11:54 -0400 Subject: [PATCH 14/23] Redirect history fix (Closes #91) --- requests/models.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/requests/models.py b/requests/models.py index 289546c2..05623ec6 100644 --- a/requests/models.py +++ b/requests/models.py @@ -170,10 +170,7 @@ class Request(object): r = build(resp) - if r.status_code in REDIRECT_STATI: - self.redirect = True - - if self.redirect: + if r.status_code in REDIRECT_STATI and not self.redirect: while ( ('location' in r.headers) and From 7f9c6233bbfd0c3e3292220254f8dcf333350905 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:12:34 -0400 Subject: [PATCH 15/23] history bugfix in history --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 5bc0d659..171dae44 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,7 @@ History * Forced Basic is default authentication type * ``python-requests.org`` default User-Agent header * CaseInsensitiveDict lower-case caching +* Response.history bugfix 0.5.0 (2011-06-21) From 7e4f7fa600c9a7d41289a78737a9b847e171526c Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:12:41 -0400 Subject: [PATCH 16/23] =?UTF-8?q?added=20Rub=C3=A9n=20Abad=20to=20AUTHORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index fd536448..bee79684 100644 --- a/AUTHORS +++ b/AUTHORS @@ -29,3 +29,4 @@ Patches and Suggestions - Jérémy Bethmont - 潘旭 (Xu Pan) - Tamás Gulácsi +- Rubén Abad \ No newline at end of file From 87560d65ca09d2065334f940f04b40ac28b0509a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:16:21 -0400 Subject: [PATCH 17/23] redirect history length test --- test_requests.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test_requests.py b/test_requests.py index 0c334577..54219350 100755 --- a/test_requests.py +++ b/test_requests.py @@ -353,5 +353,14 @@ class RequestsTestSuite(unittest.TestCase): self.assertEquals(rbody.get('data'), '') + def test_redirect_history(self): + r = requests.get(httpbin('redirect', '3')) + self.assertEquals(r.status_code, 200) + self.assertEquals(len(r.history), 3) + + r = requests.get(httpsbin('redirect', '3')) + self.assertEquals(r.status_code, 200) + self.assertEquals(len(r.history), 3) + if __name__ == '__main__': unittest.main() From c3c90bb09c9f4cd635ea28cbc784ee5f724bdab8 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:35:46 -0400 Subject: [PATCH 18/23] default headers and content encoding settings Closes #78 --- requests/config.py | 3 ++- requests/models.py | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/requests/config.py b/requests/config.py index c34a2b94..1d335f42 100644 --- a/requests/config.py +++ b/requests/config.py @@ -54,4 +54,5 @@ class Settings(object): return object.__getattribute__(self, key) settings = Settings() -settings.base_headers = {'User-Agent': 'python-requests.org'} \ No newline at end of file +settings.base_headers = {'User-Agent': 'python-requests.org'} +settings.accept_gzip = True \ No newline at end of file diff --git a/requests/models.py b/requests/models.py index a03fff63..7fb07fb3 100644 --- a/requests/models.py +++ b/requests/models.py @@ -80,9 +80,21 @@ class Request(object): #: True if Request has been sent. self.sent = False - headers = settings.base_headers - if self.headers: - headers.update(self.headers) + + # Header manipulation and defaults. + + if settings.accept_gzip: + settings.base_headers.update({'Accept-Encoding': 'gzip'}) + + if headers: + headers = CaseInsensitiveDict(self.headers) + else: + headers = CaseInsensitiveDict() + + for (k, v) in settings.base_headers.items(): + if k not in headers: + headers[k] = v + self.headers = headers From 074150ff2c625a400244110c74f4e3546d08cbca Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:42:51 -0400 Subject: [PATCH 19/23] test fix --- test_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_requests.py b/test_requests.py index 54219350..8c137fad 100755 --- a/test_requests.py +++ b/test_requests.py @@ -326,7 +326,7 @@ class RequestsTestSuite(unittest.TestCase): def test_idna(self): r = requests.get(u'http://➡.ws/httpbin') - assert 'tinyarrows.com' in r.url + assert 'httpbin' in r.url def test_urlencoded_get_query_multivalued_param(self): r = requests.get(httpbin('get'), params=dict(test=['foo','baz'])) From 3293c0e8f4e23206e81f01f2d6332c401da53f8c Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:49:01 -0400 Subject: [PATCH 20/23] Python 2.5 bugfix --- requests/monkeys.py | 1 + 1 file changed, 1 insertion(+) diff --git a/requests/monkeys.py b/requests/monkeys.py index 909626c5..c8380711 100644 --- a/requests/monkeys.py +++ b/requests/monkeys.py @@ -42,6 +42,7 @@ class HTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler): def __init__(self, *args, **kwargs): urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs) self.retried_req = None + self.retried = 0 def reset_retry_count(self): From 1cdd1d04cec8aa0ba9067a9fcef57e0b92c3ad3a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 23 Jul 2011 22:58:32 -0400 Subject: [PATCH 21/23] v0.5.1 --- .gitignore | 3 ++- requests/core.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f793004e..49e07472 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ nosetests.xml pylint.txt *.pyc docs/_build -toy.py \ No newline at end of file +toy.py +.gitignore diff --git a/requests/core.py b/requests/core.py index 87f55e45..5215fca2 100644 --- a/requests/core.py +++ b/requests/core.py @@ -12,8 +12,8 @@ This module implements the main Requests system. """ __title__ = 'requests' -__version__ = '0.5.0' -__build__ = 0x000500 +__version__ = '0.5.1' +__build__ = 0x000501 __author__ = 'Kenneth Reitz' __license__ = 'ISC' __copyright__ = 'Copyright 2011 Kenneth Reitz' From 18c42e88f5adc0c547b23905b7c2a60c0ecfe789 Mon Sep 17 00:00:00 2001 From: Peter Manser Date: Thu, 4 Aug 2011 21:47:15 +0200 Subject: [PATCH 22/23] Fixing minor bug in code example - missing apostrophe --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f4b37146..96a1f537 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ HTTPS? Basic Authentication? :: Uh oh, we're not authorized! Let's add authentication. :: - >>> r = requests.get(https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass')) + >>> r = requests.get('https://httpbin.ep.io/basic-auth/user/pass', auth=('user', 'pass')) >>> r.status_code 200 From e1714e678ec90d6ed67f95b83ed7e7c2c1a6925f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 4 Aug 2011 22:08:32 -0300 Subject: [PATCH 23/23] Added Peter Manser to AUTHORS --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index bee79684..b6e45cf4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -29,4 +29,5 @@ Patches and Suggestions - Jérémy Bethmont - 潘旭 (Xu Pan) - Tamás Gulácsi -- Rubén Abad \ No newline at end of file +- Rubén Abad +- Peter Manser \ No newline at end of file