diff --git a/AUTHORS b/AUTHORS index 4fe13730..8ac10b29 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,4 +46,5 @@ Patches and Suggestions - Josselin Jacquard - Travis N. Vaught - Fredrik Möllerstrand -- Daniel Hengeveld \ No newline at end of file +- Daniel Hengeveld +- Dan Head \ No newline at end of file diff --git a/HISTORY.rst b/HISTORY.rst index 1edef631..b32181e8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,11 @@ History ------- +0.7.4 (2011-10-26) +++++++++++++++++++ + +* Sesion Hooks fix. + 0.7.3 (2011-10-23) ++++++++++++++++++ diff --git a/requests/__init__.py b/requests/__init__.py index fd8853d9..cd7d9d72 100644 --- a/requests/__init__.py +++ b/requests/__init__.py @@ -15,15 +15,15 @@ requests """ __title__ = 'requests' -__version__ = '0.7.3' -__build__ = 0x000703 +__version__ = '0.7.4' +__build__ = 0x000704 __author__ = 'Kenneth Reitz' __license__ = 'ISC' __copyright__ = 'Copyright 2011 Kenneth Reitz' from . import utils -from .models import HTTPError, Request, Response +from .models import Request, Response from .api import request, get, head, post, patch, put, delete from .sessions import session from .status_codes import codes diff --git a/requests/async.py b/requests/async.py index 3b07f26e..92839c30 100644 --- a/requests/async.py +++ b/requests/async.py @@ -32,7 +32,10 @@ def patched(f): """Patches a given API function to not send.""" def wrapped(*args, **kwargs): - return f(*args, return_response=False, **kwargs) + + kwargs['return_response'] = False + + return f(*args, **kwargs) return wrapped diff --git a/requests/defaults.py b/requests/defaults.py index 951c056d..770001f9 100644 --- a/requests/defaults.py +++ b/requests/defaults.py @@ -26,6 +26,7 @@ defaults = dict() defaults['base_headers'] = { 'User-Agent': 'python-requests/%s' % __version__, 'Accept-Encoding': ', '.join(('identity', 'deflate', 'compress', 'gzip')), + 'Accept': '*/*' } defaults['proxies'] = {} diff --git a/requests/models.py b/requests/models.py index 1fac1a8d..fd74ed54 100644 --- a/requests/models.py +++ b/requests/models.py @@ -12,21 +12,22 @@ import urllib2 import socket import zlib -from urllib2 import HTTPError from urlparse import urlparse, urlunparse, urljoin from datetime import datetime +from .auth import dispatch as auth_dispatch from .hooks import dispatch_hook from .structures import CaseInsensitiveDict from .packages.poster.encode import multipart_encode from .packages.poster.streaminghttp import register_openers, get_handlers -from .utils import (dict_from_cookiejar, get_unicode_from_response, stream_decode_response_unicode, decode_gzip, stream_decode_gzip) from .status_codes import codes from .exceptions import Timeout, URLRequired, TooManyRedirects from .monkeys import Request as _Request from .monkeys import HTTPRedirectHandler +from .utils import ( + dict_from_cookiejar, get_unicode_from_response, + stream_decode_response_unicode, decode_gzip, stream_decode_gzip) -from .auth import dispatch as auth_dispatch REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved) diff --git a/requests/sessions.py b/requests/sessions.py index 5993b27c..eaeb96e4 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -51,7 +51,9 @@ def merge_kwargs(local_kwarg, default_kwarg): class Session(object): """A Requests session.""" - __attrs__ = ['headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks', 'params', 'config'] + __attrs__ = [ + 'headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks', + 'params', 'config'] def __init__(self, @@ -62,7 +64,8 @@ class Session(object): proxies=None, hooks=None, params=None, - config=None): + config=None, + keep_alive=True): self.headers = headers or {} self.cookies = cookies or {} @@ -72,6 +75,7 @@ class Session(object): self.hooks = hooks or {} self.params = params or {} self.config = config or {} + self.keep_alive = keep_alive for (k, v) in defaults.items(): self.config.setdefault(k, v) @@ -157,8 +161,9 @@ class Session(object): args[attr] = merge_kwargs(local_val, session_val) + # Arguments manipulation hook. - args = dispatch_hook('args', hooks, args) + args = dispatch_hook('args', args['hooks'], args) r = Request(**args) @@ -169,7 +174,6 @@ class Session(object): # Send the HTTP Request. r.send() - return r.response