Merge branch 'develop'

This commit is contained in:
Kenneth Reitz
2011-10-26 18:38:50 -04:00
7 changed files with 27 additions and 12 deletions
+2 -1
View File
@@ -46,4 +46,5 @@ Patches and Suggestions
- Josselin Jacquard
- Travis N. Vaught
- Fredrik Möllerstrand
- Daniel Hengeveld
- Daniel Hengeveld
- Dan Head
+5
View File
@@ -1,6 +1,11 @@
History
-------
0.7.4 (2011-10-26)
++++++++++++++++++
* Sesion Hooks fix.
0.7.3 (2011-10-23)
++++++++++++++++++
+3 -3
View File
@@ -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
+4 -1
View File
@@ -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
+1
View File
@@ -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'] = {}
+4 -3
View File
@@ -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)
+8 -4
View File
@@ -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