From 49bb66b95ee54101abf77be9bf332c218ddf243b Mon Sep 17 00:00:00 2001 From: maggie44 <64841595+maggie44@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:21:44 +0100 Subject: [PATCH] Restore ability to relay POST requests with empty bodies --- connection/quic.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/connection/quic.go b/connection/quic.go index b24a6cce..0f0c7965 100644 --- a/connection/quic.go +++ b/connection/quic.go @@ -550,15 +550,6 @@ func isTransferEncodingChunked(req *http.Request) bool { return strings.Contains(strings.ToLower(transferEncodingVal), "chunked") } -// Borrowed from https://github.com/golang/go/blob/go1.22.6/src/net/http/request.go#L1541 -func requestMethodUsuallyLacksBody(req *http.Request) bool { - switch strings.ToUpper(req.Method) { - case "GET", "HEAD", "DELETE", "OPTIONS", "PROPFIND", "SEARCH": - return true - } - return false -} - func shouldSetRequestBodyToEmpty(connectRequest *pogs.ConnectRequest, metadata map[string]string, req *http.Request) bool { switch metadata[HTTPRequestBodyHintKey] { case RequestBodyHintEmpty.String(): @@ -576,7 +567,7 @@ func shouldSetRequestBodyToEmpty(connectRequest *pogs.ConnectRequest, metadata m // * there is no transfer-encoding=chunked already set. // So, if transfer cannot be chunked and content length is 0, we dont set a request body. // Reference: https://github.com/golang/go/blob/go1.22.2/src/net/http/transfer.go#L192-L206 - return !isWebsocket && requestMethodUsuallyLacksBody(req) && !isTransferEncodingChunked(req) && req.ContentLength == 0 + return !isWebsocket && !isTransferEncodingChunked(req) && req.ContentLength == 0 } // A helper struct that guarantees a call to close only affects read side, but not write side.