From 1f52b51dca8996879e679a9466b66717c9684cce Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Sat, 16 May 2020 08:12:43 +0200 Subject: [PATCH] Add Content-Length to app.Test() (#387) * Add Content-Length if not provided with Body --- app.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.go b/app.go index d785530c..1d410d32 100644 --- a/app.go +++ b/app.go @@ -445,6 +445,10 @@ func (app *App) Test(request *http.Request, msTimeout ...int) (*http.Response, e if len(msTimeout) > 0 { timeout = msTimeout[0] } + // Add Content-Length if not provided with body + if request.Body != http.NoBody && request.Header.Get("Content-Length") == "" { + request.Header.Add("Content-Length", strconv.FormatInt(request.ContentLength, 10)) + } // Dump raw http request dump, err := httputil.DumpRequest(request, true) if err != nil {