Skip to content

Commit e90161d

Browse files
committed
Commit
1 parent de85bfe commit e90161d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

handler.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,11 @@ func NewBidiStreamHandler[Req, Res any](
256256

257257
// ServeHTTP implements [http.Handler].
258258
func (h *Handler) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) {
259-
260-
rc := http.NewResponseController(responseWriter)
261-
rc.SetReadDeadline(time.Now().Add(time.Duration(h.spec.ReadTimeout) * time.Nanosecond))
262-
rc.SetWriteDeadline(time.Now().Add(time.Duration(h.spec.ReadTimeout) * time.Nanosecond))
259+
if h.spec.ReadTimeout != 0 {
260+
rc := http.NewResponseController(responseWriter)
261+
rc.SetReadDeadline(time.Now().Add(time.Duration(h.spec.ReadTimeout) * time.Nanosecond))
262+
rc.SetWriteDeadline(time.Now().Add(time.Duration(h.spec.ReadTimeout) * time.Nanosecond))
263+
}
263264

264265
// We don't need to defer functions to close the request body or read to
265266
// EOF: the stream we construct later on already does that, and we only

0 commit comments

Comments
 (0)