From 21542e2efe31398d1278a3d81fa54d2e0636e2d5 Mon Sep 17 00:00:00 2001 From: wuzihui Date: Wed, 17 Jul 2024 11:06:52 +0800 Subject: [PATCH] add SetReadHeaderTimeout --- protocol.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/protocol.go b/protocol.go index 658900a..3b40306 100644 --- a/protocol.go +++ b/protocol.go @@ -63,6 +63,15 @@ func ValidateHeader(v Validator) func(*Conn) { } } +// SetReadHeaderTimeout sets the readHeaderTimeout for a connection when passed as option to NewConn() +func SetReadHeaderTimeout(t time.Duration) func(*Conn) { + return func(c *Conn) { + if t >= 0 { + c.readHeaderTimeout = t + } + } +} + // Accept waits for and returns the next connection to the listener. func (p *Listener) Accept() (net.Conn, error) { // Get the underlying connection