mirror of https://github.com/scrapy/scrapy.git
response_httprepr: fixed error with unknown response codes (closes #169)
This commit is contained in:
parent
2571e1b7aa
commit
22555df56a
|
|
@ -129,6 +129,9 @@ class ResponseUtilsTest(unittest.TestCase):
|
|||
r1 = Response("http://www.example.com", status=404, headers={"Content-type": "text/html"}, body="Some body")
|
||||
self.assertEqual(response_httprepr(r1), 'HTTP/1.1 404 Not Found\r\nContent-Type: text/html\r\n\r\nSome body')
|
||||
|
||||
r1 = Response("http://www.example.com", status=6666, headers={"Content-type": "text/html"}, body="Some body")
|
||||
self.assertEqual(response_httprepr(r1), 'HTTP/1.1 6666 \r\nContent-Type: text/html\r\n\r\nSome body')
|
||||
|
||||
def test_get_cached_beautifulsoup(self):
|
||||
r1 = Response('http://www.example.com', body='')
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ def response_httprepr(response):
|
|||
that was received (that's not exposed by Twisted).
|
||||
"""
|
||||
|
||||
s = "HTTP/1.1 %d %s\r\n" % (response.status, RESPONSES[response.status])
|
||||
s = "HTTP/1.1 %d %s\r\n" % (response.status, RESPONSES.get(response.status, ''))
|
||||
if response.headers:
|
||||
s += response.headers.to_string() + "\r\n"
|
||||
s += "\r\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue