From e1ac7c88ab3b9c60bfb3c3ee244133a347e5f50f Mon Sep 17 00:00:00 2001 From: Haruue Date: Thu, 30 May 2024 22:55:39 +0800 Subject: [PATCH 1/2] fix(client/http): ffmpeg not works with proxy Go's resp.Write() adds a "Content-Length: 0" header and it seems that ffmpeg doesn't like this and immediately closes the proxy connection. close: #1109 --- app/internal/http/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/internal/http/server.go b/app/internal/http/server.go index e5761ce5f1..760e9e1d45 100644 --- a/app/internal/http/server.go +++ b/app/internal/http/server.go @@ -278,6 +278,9 @@ func sendSimpleResponse(conn net.Conn, req *http.Request, statusCode int) error ProtoMinor: req.ProtoMinor, Header: http.Header{}, } + // Remove the "Content-Length: 0" header, some clients (e.g. ffmpeg) may not like it. + // NOTE: This will also cause go/http to add a "Connection: close" header, but seems to be fine. + resp.ContentLength = -1 return resp.Write(conn) } From 23b79688fbd5a777c9ee7a38d5084263d2f3d859 Mon Sep 17 00:00:00 2001 From: Haruue Date: Thu, 30 May 2024 23:12:27 +0800 Subject: [PATCH 2/2] chore(client/http): rm "Connection: close" header Magic of undocumented features. --- app/internal/http/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/internal/http/server.go b/app/internal/http/server.go index 760e9e1d45..0b5e411665 100644 --- a/app/internal/http/server.go +++ b/app/internal/http/server.go @@ -279,8 +279,10 @@ func sendSimpleResponse(conn net.Conn, req *http.Request, statusCode int) error Header: http.Header{}, } // Remove the "Content-Length: 0" header, some clients (e.g. ffmpeg) may not like it. - // NOTE: This will also cause go/http to add a "Connection: close" header, but seems to be fine. resp.ContentLength = -1 + // Also, prevent the "Connection: close" header. + resp.Close = false + resp.Uncompressed = true return resp.Write(conn) }