From bc5f1163e752bbf535b96051104d067f3526502a Mon Sep 17 00:00:00 2001 From: Harry Li Date: Thu, 7 Mar 2024 17:01:00 +0800 Subject: [PATCH] fix: Improper handling of empty POST requests --- jsr311.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsr311.go b/jsr311.go index 07a0c91e..a9b3faaa 100644 --- a/jsr311.go +++ b/jsr311.go @@ -155,7 +155,7 @@ func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*R method, length := httpRequest.Method, httpRequest.Header.Get("Content-Length") if (method == http.MethodPost || method == http.MethodPut || - method == http.MethodPatch) && length == "" { + method == http.MethodPatch) && (length == "" || length == "0") { return nil, NewError( http.StatusUnsupportedMediaType, fmt.Sprintf("415: Unsupported Media Type\n\nAvailable representations: %s", strings.Join(available, ", ")),