Omitting a forward slash from http domain produces Bad HTTP request line
See original GitHub issueProblem Description
Running a GET request for “http://wikipedia.com” will produce the following output:
35.176.198.120:43784: clientconnect << Bad HTTP request line: b'GET http://wikipedia.com HTTP/1.1' ::ffff:35.176.198.120:43784: request -> HTTP protocol error in client request: Bad HTTP request line: b'GET http://wikipedia.com HTTP/1.1' 35.176.198.120:43784: clientdisconnect
The request status, headers and body are as follows for the client:
400 <CIMultiDictProxy('Server': 'mitmproxy 5.3.0', 'Connection': 'close', 'Content-Length': '306', 'Content-Type': 'text/html')> b'<html>\n <head>\n <title>400 Bad Request</title>\n </head>\n <body>\n <h1>400 Bad Request</h1>\n <p>HttpSyntaxException("Bad HTTP request line: b'GET http://wikipedia.com HTTP/1.1'")</p>\n </body>\n </html>
Running a GET request for “http://wikipedia.com/” will not produce this error. Nor will “https://wikipedia.com”. Curl runs the problematic URL fine as it appends the missing trailing slash before running the request which can be seen by printing flow.request.url.
Steps to reproduce the behavior:
- Start mitmproxy using “mitmdump -s proxy_server.py --set block_global=false”
- Run a GET request with mitm proxy as the request proxy for “http://wikipedia.com”.
System Information
Mitmproxy: 5.3.0 Python: 3.7.9 OpenSSL: OpenSSL 1.1.1h 22 Sep 2020 Platform: Linux-4.14.203-156.332.amzn2.x86_64-x86_64-with-glibc2.2.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
This document (RFC 7230) says that providing “/” as a path in case of empty URI’s path component is a MUST.
@pdelagrave: you’re encouraged to switch to master (we do have binaries for dev snapshots as well) and report more bugs there 😃