Merge pull request #165 from akun/master

Fixed an error when "Content-Length" is not int like
This commit is contained in:
Gabriel Falcão 2017-02-16 17:25:01 -05:00 committed by GitHub
commit 6d26203673
2 changed files with 4 additions and 1 deletions

View File

@ -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 '

View File

@ -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',
})