From: Kenneth Reitz Date: Mon, 17 Dec 2012 12:01:59 +0000 (-0500) Subject: tension X-Git-Tag: v1.0.0~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3431bb6f21bf7c88ff86d9a232ba4db54bb91a0;p=services%2Fpython-requests.git tension --- diff --git a/requests/models.py b/requests/models.py index 92f2baf..374d09f 100644 --- a/requests/models.py +++ b/requests/models.py @@ -7,13 +7,9 @@ requests.models This module contains the primary objects that power Requests. """ -# import os -# import socket - import collections import logging -# from datetime import datetime from io import BytesIO from .hooks import dispatch_hook, default_hooks from .structures import CaseInsensitiveDict diff --git a/requests/sessions.py b/requests/sessions.py index c709183..8c4a491 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -10,10 +10,10 @@ requests (cookies, auth, proxies). """ from .compat import cookielib -from .cookies import cookiejar_from_dict, remove_cookie_by_name +from .cookies import cookiejar_from_dict from .models import Request from .hooks import dispatch_hook, default_hooks -from .utils import header_expand, from_key_val_list, default_headers +from .utils import from_key_val_list, default_headers from .exceptions import TooManyRedirects, InvalidSchema from .compat import urlparse, urljoin @@ -354,8 +354,6 @@ class Session(SessionRedirectMixin): for attr, value in state.items(): setattr(self, attr, value) - self.init_poolmanager() - def session(**kwargs): """Returns a :class:`Session` for context-management.""" diff --git a/requests/utils.py b/requests/utils.py index ca4591f..fb098aa 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -254,56 +254,6 @@ def unquote_header_value(value, is_filename=False): return value -def header_expand(headers): - """Returns an HTTP Header value string from a dictionary. - - Example expansion:: - - {'text/x-dvi': {'q': '.8', 'mxb': '100000', 'mxt': '5.0'}, 'text/x-c': {}} - # Accept: text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c - - (('text/x-dvi', {'q': '.8', 'mxb': '100000', 'mxt': '5.0'}), ('text/x-c', {})) - # Accept: text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c - """ - - collector = [] - - if isinstance(headers, dict): - headers = list(headers.items()) - elif isinstance(headers, basestring): - return headers - elif isinstance(headers, str): - # As discussed in https://github.com/kennethreitz/requests/issues/400 - # latin-1 is the most conservative encoding used on the web. Anyone - # who needs more can encode to a byte-string before calling - return headers.encode("latin-1") - elif headers is None: - return headers - - for i, (value, params) in enumerate(headers): - - _params = [] - - for (p_k, p_v) in list(params.items()): - - _params.append('%s=%s' % (p_k, p_v)) - - collector.append(value) - collector.append('; ') - - if len(params): - - collector.append('; '.join(_params)) - - if not len(headers) == i + 1: - collector.append(', ') - - # Remove trailing separators. - if collector[-1] in (', ', '; '): - del collector[-1] - - return ''.join(collector) - def dict_from_cookiejar(cj): """Returns a key/value dictionary from a CookieJar. @@ -423,8 +373,7 @@ def get_unicode_from_response(r): def stream_decompress(iterator, mode='gzip'): - """ - Stream decodes an iterator over compressed data + """Stream decodes an iterator over compressed data :param iterator: An iterator over compressed data :param mode: 'gzip' or 'deflate'