Fix connection termination when using HTTP proxies#427
Draft
Conversation
When using an HTTP proxy (like v2ray), rtp2httpd was forwarding upstream response headers without ensuring Connection: close was present. This caused HTTP proxies to keep connections alive even when clients disconnected or switched channels. Changes: - Filter out Connection header from upstream responses - Always inject Connection: close in responses to clients - Add e2e tests to verify Connection: close header presence Fixes issue where connections cannot be terminated when switching channels or closing browser while using system proxy. Co-authored-by: stackia <5107241+stackia@users.noreply.github.com> Agent-Logs-Url: https://github.com/stackia/rtp2httpd/sessions/492e1c66-6b45-40a3-9efa-2f9757bb72a4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using HTTP proxies (e.g., v2ray), rtp2httpd forwarded upstream response headers without ensuring
Connection: closewas present, causing proxies to keep connections alive indefinitely even after clients disconnected or switched channels.Changes
Modified HTTP proxy response header handling (
src/http_proxy.c:1027-1172)Connectionheaders in both redirect and normal response pathsConnection: closeheader before sending headers to clientsAdded e2e tests (
e2e/test_http_proxy.py:500-592)Connection: closepresence in normal responsesConnection: closepresence in redirect responseskeep-aliveis correctly overridden withcloseTechnical Details
The fix modifies
http_proxy_parse_response_headers()to parse and rebuild response headers, skipping anyConnectionheader from upstream:This ensures HTTP proxies correctly terminate connections when clients disconnect, fixing the issue where switching channels or closing browsers left connections hanging.
Original prompt