fix(tls): flush early API responses before request body teardown

This commit is contained in:
2026-11-22 19:37:57 +03:00
parent 87d71cba8f
commit 3c8db323c4
4 changed files with 50 additions and 5 deletions
+5
View File
@@ -361,6 +361,11 @@ func (l *boundedListener) Accept() (net.Conn, error) {
}
func loopbackProxy(c Config, target *url.URL) *httputil.ReverseProxy {
proxy := httputil.NewSingleHostReverseProxy(target)
if c.Role == "api" {
// Deliver the application's early error before request-body teardown.
// Otherwise a large upload can close the hop before buffered JSON drains.
proxy.FlushInterval = -1
}
director := proxy.Director
proxy.Director = func(r *http.Request) {
director(r)