Fixed an error when "Content-Length" is not int like
This commit is contained in:
parent
849682dee1
commit
876d8c862b
@ -510,6 +510,7 @@ class Entry(BaseClass):
|
||||
if got is None:
|
||||
continue
|
||||
|
||||
igot = None
|
||||
try:
|
||||
igot = int(got)
|
||||
except ValueError:
|
||||
@ -518,7 +519,7 @@ class Entry(BaseClass):
|
||||
'with "%r" which is not a number' % got,
|
||||
)
|
||||
|
||||
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