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