Skip to content

Commit

Permalink
Only log response text if needed
Browse files Browse the repository at this point in the history
Fixes #16.

This can result in `chardet` being used even if the debug statement isn't
required which can be very slow on large responses (e.g. PDFs).
  • Loading branch information
StevenMaude committed Mar 18, 2015
1 parent 7f7525b commit e48b372
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dshelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ def _download_without_backoff(url, as_file=True, **kwargs):
kwargs_copy['headers'] = CaseInsensitiveDict({'user-agent': _USER_AGENT})

response = requests.get(url, **kwargs_copy)

L.debug('"{}"'.format(response.text))

if logging.getLogger().isEnabledFor(logging.DEBUG):
L.debug('"{}"'.format(response.text))

response.raise_for_status()

Expand Down

0 comments on commit e48b372

Please sign in to comment.