1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

Add timeout for http request roundtripper

This commit is contained in:
Shelikhoo 2024-05-04 07:09:26 +01:00 committed by Xiaokang Wang (Shelikhoo)
parent 346ca66c57
commit 8b8a786c16

View File

@ -9,6 +9,7 @@ import (
"io"
gonet "net"
"net/http"
"time"
"github.com/v2fly/v2ray-core/v5/transport/internet/transportcommon"
@ -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()
}