From ddcfb298169fd8cdb443e7ff4f5afef7d35969f8 Mon Sep 17 00:00:00 2001 From: ikawaha Date: Tue, 17 Oct 2023 08:22:23 +0900 Subject: [PATCH] chore: Fix potential slowloris attack (GO-S2112) --- cmd/server/cmd.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/server/cmd.go b/cmd/server/cmd.go index da7a16d..40f0fc2 100644 --- a/cmd/server/cmd.go +++ b/cmd/server/cmd.go @@ -11,6 +11,7 @@ import ( "os" "os/signal" "syscall" + "time" "github.com/ikawaha/kagome-dict/dict" "github.com/ikawaha/kagome-dict/ipa" @@ -106,8 +107,9 @@ func command(ctx context.Context, opt *option) error { mux.Handle("/", &TokenizeDemoHandler{tokenizer: t}) mux.Handle("/tokenize", &TokenizeHandler{tokenizer: t}) srv := http.Server{ - Addr: opt.http, - Handler: mux, + Addr: opt.http, + Handler: mux, + ReadHeaderTimeout: 20 * time.Second, } ch := make(chan error) go func() {