From 6f0d16c7ee3cc2d6bac040891873e0ada3ca7dfe Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Wed, 8 Dec 2021 14:49:34 +0100 Subject: [PATCH] fixed HEAD requests not being processed --- internal/handler/handler.go | 5 +++++ main.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/handler/handler.go b/internal/handler/handler.go index 102afba..5b57f41 100644 --- a/internal/handler/handler.go +++ b/internal/handler/handler.go @@ -14,6 +14,11 @@ func FasthttpHandler(ctx *fasthttp.RequestCtx) { defer func(t time.Time) { glog.Debugf("request took %s", time.Since(t)) }(t) remoteAddr := ctx.RemoteIP().String() + if string(ctx.Method()) != "GET" && string(ctx.Method()) != "HEAD" { + ctx.SetStatusCode(fasthttp.StatusBadRequest) + return + } + if header := viper.GetString("IPHeaderField"); header != "" { remoteAddr = string(ctx.Request.Header.Peek(header)) } diff --git a/main.go b/main.go index d16932d..5b83b38 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,7 @@ func main() { Handler: handler.FasthttpHandler, Name: "gomod-recter/" + Version, Concurrency: 128, - GetOnly: true, + GetOnly: false, DisablePreParseMultipartForm: true, LogAllErrors: true, SecureErrorLogMessage: true, -- 2.45.2