Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve confusing log messages if someone accidentally accesses the Web UI over HTTPS #2727

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,17 @@ def start_server(self):
(self.host, self.port), self.app, log=None, keyfile=self.tls_key, certfile=self.tls_cert
)
else:
self.server = pywsgi.WSGIServer((self.host, self.port), self.app, log=None)

class RewriteFilter(logging.Filter):
def filter(self, record) -> bool:
msg = record.msg
if msg.find("gevent._socket3.socket at") and msg.find("Invalid HTTP method: '\x16\x03"):
record.msg = f"A request against Locust's Web UI was made using https:// instead of http:// (underlying error was {record.msg})"
return True

logger.addFilter(RewriteFilter())
self.server = pywsgi.WSGIServer((self.host, self.port), self.app, log=None, error_log=logger)

self.server.serve_forever()

def stop(self):
Expand Down
Loading