Skip to content

Commit

Permalink
properly handle send(prefetch=False)
Browse files Browse the repository at this point in the history
fixes RequestsTestSuite.test_prefetch_return_response_interaction
  • Loading branch information
slingamn committed Aug 6, 2012
1 parent 857d8ed commit 030ead9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions requests/models.py
Expand Up @@ -458,7 +458,7 @@ def deregister_hook(self, event, hook):
except ValueError:
return False

def send(self, anyway=False, prefetch=True):
def send(self, anyway=False, prefetch=None):
"""Sends the request. Returns True if successful, False if not.
If there was an HTTPError during transmission,
self.response.status_code will contain the HTTPError code.
Expand All @@ -467,6 +467,9 @@ def send(self, anyway=False, prefetch=True):
:param anyway: If True, request will be sent, even if it has
already been sent.
:param prefetch: If not None, will override the request's own setting
for prefetch.
"""

# Build the URL
Expand Down Expand Up @@ -626,7 +629,9 @@ def send(self, anyway=False, prefetch=True):
self.__dict__.update(r.__dict__)

# If prefetch is True, mark content as consumed.
if prefetch or self.prefetch:
if prefetch is None:
prefetch = self.prefetch
if prefetch:
# Save the response.
self.response.content

Expand Down

0 comments on commit 030ead9

Please sign in to comment.