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

Fix TrustedHostMiddleware Handling for WebSocket Connections #2511

Conversation

Massakera
Copy link
Contributor

@Massakera Massakera commented Feb 14, 2024

Summary

This PR addresses a runtime exception encountered when making WebSocket requests without a Host header or with an invalid Host header, resulting in a RuntimeError due to an inappropriate response type. The existing TrustedHostMiddleware does not properly handle WebSocket connections in such scenarios, attempting to send an HTTP response where a WebSocket response is expected.

fix #2420

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Sponsor Member

Kludex commented Feb 15, 2024

Since this is not an issue anymore, I'll close this PR.

Thanks anyway.

@Kludex Kludex closed this Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TrustedHostMiddleware raises RuntimeError on sending response to websocket
2 participants