Skip to content

Commit

Permalink
Add timeout for http request roundtripper
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokangwang committed May 5, 2024
1 parent 346ca66 commit 8b8a786
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion transport/internet/request/roundtripper/httprt/httprt.go
Expand Up @@ -9,6 +9,7 @@ import (
"io"
gonet "net"
"net/http"
"time"

"github.com/v2fly/v2ray-core/v5/transport/internet/transportcommon"

Expand Down Expand Up @@ -119,7 +120,14 @@ func (h *httpTripperServer) Start() error {
}
h.listener = listener
go func() {
err := http.Serve(listener, h)
httpServer := http.Server{
ReadHeaderTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 30 * time.Second,
}
httpServer.Handler = h
err := httpServer.Serve(h.listener)
if err != nil {
newError("unable to serve listener for http tripper server").Base(err).WriteToLog()
}
Expand Down

0 comments on commit 8b8a786

Please sign in to comment.