~poldi1405/gomod-recter

6f0d16c7ee3cc2d6bac040891873e0ada3ca7dfe — Moritz Poldrack 2 years ago 654b748
fixed HEAD requests not being processed
2 files changed, 6 insertions(+), 1 deletions(-)

M internal/handler/handler.go
M main.go
M internal/handler/handler.go => internal/handler/handler.go +5 -0
@@ 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))
	}

M main.go => main.go +1 -1
@@ 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,