Skip to content

Commit efab88d

Browse files
author
Doug Davis
committed
Add ReadHeaderTimeout for security
Closes #821 Signed-off-by: Doug Davis <[email protected]>
1 parent 2298be0 commit efab88d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

v2/protocol/http/abuse_protection.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"net/http"
1313
"strconv"
1414
"strings"
15+
"time"
1516
)
1617

1718
type WebhookConfig struct {
@@ -23,6 +24,7 @@ type WebhookConfig struct {
2324

2425
const (
2526
DefaultAllowedRate = 1000
27+
DefaultTimeout = time.Second * 600
2628
)
2729

2830
// TODO: implement rate limiting.

v2/protocol/http/protocol_lifecycle.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ func (p *Protocol) OpenInbound(ctx context.Context) error {
3838
}
3939

4040
p.server = &http.Server{
41-
Addr: listener.Addr().String(),
42-
Handler: attachMiddleware(p.Handler, p.middleware),
41+
Addr: listener.Addr().String(),
42+
Handler: attachMiddleware(p.Handler, p.middleware),
43+
ReadTimeout: DefaultTimeout,
44+
WriteTimeout: DefaultTimeout,
4345
}
4446

4547
// Shutdown

0 commit comments

Comments
 (0)