From 2d5b92f4644a70bd9e9e220e767594582ca9e1b1 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Fri, 30 Dec 2022 20:18:27 +0100 Subject: [PATCH] httpx.Response: Add 'Content-Length' header --- pkg/httpx/httpx.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/httpx/httpx.go b/pkg/httpx/httpx.go index d135b4a..b9b23b9 100644 --- a/pkg/httpx/httpx.go +++ b/pkg/httpx/httpx.go @@ -2,6 +2,7 @@ package httpx import ( "net/http" + "strconv" ) // Response represents a response to an http request. @@ -16,6 +17,7 @@ func (response Response) ServeHTTP(w http.ResponseWriter, r *http.Request) { response.ContentType = "text/plain" } w.Header().Set("Content-Type", response.ContentType) + w.Header().Set("Content-Length", strconv.Itoa(len(response.Body))) if response.StatusCode <= 0 { response.StatusCode = http.StatusOK