From 2fb985375468f8d33ef2badf63495ab97c509bc5 Mon Sep 17 00:00:00 2001 From: Kalle Carlbark Date: Tue, 20 Aug 2024 13:40:51 +0200 Subject: [PATCH] handle gzipped requests som more --- main.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 83d51fa..c618b63 100644 --- a/main.go +++ b/main.go @@ -23,10 +23,8 @@ func requestHandler(w http.ResponseWriter, r *http.Request) { if r.Header.Get("Content-Encoding") == "gzip" { gzipreader, _ := gzip.NewReader(r.Body) requestbody, _ = io.ReadAll(gzipreader) - } - requestbody, err := io.ReadAll(r.Body) - if err != nil { - http.Error(w, "unable to read response", http.StatusBadRequest) + } else { + requestbody, _ = io.ReadAll(r.Body) } fmt.Printf("\n--- BODY ---\n%s\n", string(requestbody)) }