Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #319 from gittip/issue289
Fix #289 - Website should work with wsgiref
  • Loading branch information
chadwhitacre committed Apr 1, 2014
2 parents 3820bf8 + 943cb8a commit d14d9aa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions aspen/http/request.py
Expand Up @@ -635,7 +635,8 @@ def __init__(self, headers, fp, server_software):
"""
typecheck(headers, Headers, server_software, str)
self.raw = self._read_raw(server_software, fp) # XXX lazy!
raw_len = int(headers.get('Content-length', '') or '0')
self.raw = self._read_raw(server_software, fp, raw_len) # XXX lazy!
parsed = self._parse(headers, self.raw)
if parsed is None:
# There was no content-type. Use self.raw.
Expand All @@ -652,11 +653,11 @@ def __init__(self, headers, fp, server_software):
self[k] = v


def _read_raw(self, server_software, fp):
"""Given str and a file-like object, return a bytestring.
def _read_raw(self, server_software, fp, raw_len):
"""Given str, a file-like object, and the number of expected bytes, return a bytestring.
"""
if not server_software.startswith('Rocket'): # normal
raw = fp.read()
raw = fp.read(raw_len)
else: # rocket

# Email from Rocket guy: While HTTP stipulates that you shouldn't
Expand Down Expand Up @@ -686,7 +687,7 @@ def _read_raw(self, server_software, fp):
_tmp = fp._sock.timeout
fp._sock.settimeout(0) # equiv. to non-blocking
try:
raw = fp.read()
raw = fp.read(raw_len)
except Exception, exc:
if exc.errno != 35:
raise
Expand Down

0 comments on commit d14d9aa

Please sign in to comment.