Commit Graph

2 Commits

Author SHA1 Message Date
Jianhui Zhao
d2e73ae6f7 refactor http proxy request handling and improve performance
This commit significantly optimizes the HTTP proxy implementation by:

1. Replacing standard http.ReadRequest with manual HTTP header parsing
   - Avoids unnecessary allocations from full request parsing
   - Adds 3-second timeout for initial header reading

2. Removing HttpProxyWriter abstraction
   - Directly construct and send rewritten Host header
   - Simplify data forwarding logic

3. Unifying WebSocket and regular HTTP handling
   - Use single read loop for both cases
   - Always use buffer pool for reads

4. Adding proper timeouts
   - Set deadlines for header reading
   - Reset timeout after headers are processed

These changes reduce memory allocations, improve performance, and simplify the proxy logic.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
2025-08-12 22:52:00 +08:00
Jianhui Zhao
1ef76bd855 Write the HTTP proxy error page to a file
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
2025-08-12 22:50:33 +08:00