Merge pull request #165 from akun/master
Fixed an error when "Content-Length" is not int like
This commit is contained in:
commit
6d26203673
@ -622,6 +622,7 @@ class Entry(BaseClass):
|
||||
if got is None:
|
||||
continue
|
||||
|
||||
igot = None
|
||||
try:
|
||||
igot = int(got)
|
||||
except (ValueError, TypeError):
|
||||
@ -630,7 +631,7 @@ class Entry(BaseClass):
|
||||
'with "%r" which is not a number' % got)
|
||||
return
|
||||
|
||||
if igot > self.body_length:
|
||||
if igot and igot > self.body_length:
|
||||
raise HTTPrettyError(
|
||||
'HTTPretty got inconsistent parameters. The header '
|
||||
'Content-Length you registered expects size "%d" but '
|
||||
|
@ -133,6 +133,7 @@ def test_httpretty_should_allow_forcing_headers_urllib2():
|
||||
body="this is supposed to be the response",
|
||||
forcing_headers={
|
||||
'Content-Type': 'application/xml',
|
||||
'Content-Length': '35a',
|
||||
})
|
||||
|
||||
request = urlopen('http://github.com')
|
||||
@ -141,6 +142,7 @@ def test_httpretty_should_allow_forcing_headers_urllib2():
|
||||
|
||||
expect(headers).to.equal({
|
||||
'content-type': 'application/xml',
|
||||
'content-length': '35a',
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user