Closed
Description
Describe the bug
NOTE: Happens only for HTTP/1.0 scenarios.
I have seen this bug only while browsing my router gateway
via 192.168.1.1
. My home gateway doesn't seem to send any content-length
header or indicate that the response will be chunked. This breaks HttpParser
class which expects one of the header to be present. Resulting in NotImplementedError
https://github.com/abhinavsingh/proxy.py/blob/develop/proxy/http/parser.py#L174-L175
To Reproduce
Steps to reproduce the behavior:
$ python
>>> from proxy.http.parser import HttpParser, httpParserTypes
>>> p = HttpParser(httpParserTypes.RESPONSE_PARSER)
>>> p.parse(b'HTTP/1.0 200 OK\r\nCP=CAO PSA OUR\r\nCache-Control:private,max-age=0;\r\nX-Frame-Options:SAMEORIGIN\r\nX-Content-Type-Options:nosniff\r\nX-XSS-Protection:1; mode=block\r\nContent-Security-Policy:default-src \'self\' \'unsafe-inline\' \'unsafe-eval\'\r\nStrict-Transport-Security:max-age=2592000; includeSubdomains\r\nSet-Cookie: lang=eng; path=/;HttpOnly;\r\nContent-type:text/html;charset=UTF-8;\r\n\r\n<!-- HTML RESPONSE HERE -->')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/parser.py", line 175, in parse
'Response headers doesn\'t contain content-length header and neither is chunked encoded.')
NotImplementedError: Parser shouldn't have reached here
Expected behavior
Trust server implementation and wait till server has closed the connection.