Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: seanjensengrey/requests
base: d79de2fe38
...
head fork: seanjensengrey/requests
compare: 195e07ca09
  • 11 commits
  • 5 files changed
  • 0 commit comments
  • 3 contributors
Commits on Jan 28, 2012
@seanjensengrey unicode fix in header_expand, Makefile improvements 2b28ab7
Commits on Jan 29, 2012
@kennethreitz kennethreitz only do oreos for 2 e695941
@acdha acdha Minor PEP-8 cleanup 49bed18
@acdha acdha Consistent self.cookies usage
This avoids two variables pointing to the same thing and avoids
a duplicate dict update() call
3020d0e
@acdha acdha Initial stop-the-bleeding fix
This is redundant but it avoids crashing otherwise working code. The code-smell
from duplication suggests that this interface should be refactored slightly.
730c0e2
@kennethreitz kennethreitz Release redirected connections. 4516bd4
@acdha acdha async: force prefetch=True on send
… otherwise we can run out of sockets before any of the responses are ever
processed
495646b
@acdha acdha Revert "Initial stop-the-bleeding fix"
This reverts commit 730c0e2.
b98cc8b
@acdha acdha Less redundant freeing of resources on redirects
With 495646b the double flush is no longer
needed.
67f50a0
Commits on Jan 30, 2012
@kennethreitz kennethreitz Merge branch '239-socket-leak' of https://github.com/acdha/requests i…
…nto develop
319b1ed
@seanjensengrey Merge branch 'develop' of https://github.com/kennethreitz/requests in…
…to develop

Conflicts:
	requests/async.py
195e07c
View
26 Makefile
@@ -10,10 +10,28 @@ init:
pip install -r requirements.txt
test:
- nosetests --with-color
+ nosetests -s --with-color test_requests.py
+ nosetests -s --with-color test_requests_ext.py
+ nosetests -s --with-color test_requests_async.py
+
test-2.5:
- nosetests-2.5 --with-color
+ nosetests-2.5 --with-color test_requests.py
+ nosetests-2.5 --with-color test_requests_ext.py
+ nosetests-2.5 --with-color test_requests_async.py
+
+
+test-jython:
+ jython-nosetests --with-color test_requests.py
+ jython-nosetests --with-color test_requests_ext.py
+ jython-nosetests --with-color test_requests_async.py
+
+
+test-jython-debug:
+ jython-nosetests -s --with-color test_requests.py
+ jython-nosetests -s --with-color test_requests_ext.py
+ jython-nosetests -s --with-color test_requests_async.py
+
lazy:
nosetests --with-color test_requests.py
@@ -31,7 +49,9 @@ site:
cd docs; make dirhtml
pyc:
- find . -name "*.pyc" -exec rm '{}' ';'
+ find . -name '*.pyc' -exec rm '{}' ';'
+ find . -name '*.class' -exec rm '{}' ';'
+
deps:
rm -fr requests/packages/urllib3
View
10 requests/async.py
@@ -46,15 +46,15 @@ def wrapped(*args, **kwargs):
return wrapped
-def send(r, pool=None):
- """Sends the request object using the specified pool. If a pool isn't
+def send(r, pool=None, prefetch=False):
+ """Sends the request object using the specified pool. If a pool isn't
specified this method blocks. Pools are useful because you can specify size
and can hence limit concurrency."""
if pool != None:
- return pool.spawn(r.send)
+ return pool.spawn(r.send, prefetch=prefetch)
- return gevent.spawn(r.send)
+ return gevent.spawn(r.send, prefetch=prefetch)
# Patched requests.api functions.
@@ -79,7 +79,7 @@ def map(requests, prefetch=True, size=None):
requests = list(requests)
pool = Pool(size) if size else None
- jobs = [send(r, pool) for r in requests]
+ jobs = [send(r, pool, prefetch=prefetch) for r in requests]
gevent.joinall(jobs)
if prefetch:
View
17 requests/models.py
@@ -203,19 +203,21 @@ def build(resp):
history = []
r = build(resp)
- cookies = self.cookies
+
self.cookies.update(r.cookies)
if r.status_code in REDIRECT_STATI and not self.redirect:
+ while (('location' in r.headers) and
+ ((r.status_code is codes.see_other) or (self.allow_redirects))):
- while (
- ('location' in r.headers) and
- ((r.status_code is codes.see_other) or (self.allow_redirects))
- ):
+ r.content # Consume socket so it can be released
if not len(history) < self.config.get('max_redirects'):
raise TooManyRedirects()
+ # Release the connection back into the pool.
+ r.raw.release_conn()
+
history.append(r)
url = r.headers['location']
@@ -250,7 +252,7 @@ def build(resp):
method=method,
params=self.session.params,
auth=self.auth,
- cookies=cookies,
+ cookies=self.cookies,
redirect=True,
config=self.config,
timeout=self.timeout,
@@ -261,7 +263,6 @@ def build(resp):
)
request.send()
- cookies.update(request.response.cookies)
r = request.response
self.cookies.update(r.cookies)
@@ -504,7 +505,7 @@ def send(self, anyway=False, prefetch=False):
# Attach Cookie header to request.
self.headers['Cookie'] = cookie_header
-
+
# Pre-request hook.
r = dispatch_hook('pre_request', self.hooks, self)
self.__dict__.update(r.__dict__)
View
3  requests/utils.py
@@ -149,6 +149,9 @@ def header_expand(headers):
elif isinstance(headers, str):
return headers
+ elif isinstance(headers, unicode):
+ return headers
+
for i, (value, params) in enumerate(headers):
_params = []
View
21 setup.py
@@ -4,7 +4,7 @@
import os
import sys
import requests
-from requests.compat import is_py3
+from requests.compat import is_py3, is_py2
try:
from setuptools import setup
@@ -22,11 +22,20 @@
sys.exit()
required = ['certifi>=0.0.7',]
+packages = [
+ 'requests',
+ 'requests.packages',
+ 'requests.packages.urllib3',
+ 'requests.packages.urllib3.packages',
+ 'requests.packages.urllib3.packages.ssl_match_hostname',
+ 'requests.packages.urllib3.packages.mimetools_choose_boundary',
+]
if is_py3:
required.append('chardet2')
else:
required.append('chardet>=1.0.0')
+ packages.append('requests.packages.oreos')
setup(
@@ -38,15 +47,7 @@
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
url='http://python-requests.org',
- packages=[
- 'requests',
- 'requests.packages',
- 'requests.packages.urllib3',
- 'requests.packages.urllib3.packages',
- 'requests.packages.urllib3.packages.ssl_match_hostname',
- 'requests.packages.urllib3.packages.mimetools_choose_boundary',
- 'requests.packages.oreos'
- ],
+ packages=packages,
package_data={'': ['LICENSE', 'NOTICE']},
include_package_data=True,
install_requires=required,

No commit comments for this range

Something went wrong with that request. Please try again.