mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
close connection when content length unknown
This commit is contained in:
parent
18904e9adb
commit
9db86e871e
@ -221,6 +221,8 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
|
|||||||
output := ray.InboundOutput()
|
output := ray.InboundOutput()
|
||||||
defer input.Close()
|
defer input.Close()
|
||||||
|
|
||||||
|
var result error = errWaitAnother
|
||||||
|
|
||||||
requestDone := signal.ExecuteAsync(func() error {
|
requestDone := signal.ExecuteAsync(func() error {
|
||||||
request.Header.Set("Connection", "close")
|
request.Header.Set("Connection", "close")
|
||||||
|
|
||||||
@ -241,6 +243,9 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
|
|||||||
response.Header.Set("Connection", "keep-alive")
|
response.Header.Set("Connection", "keep-alive")
|
||||||
response.Header.Set("Keep-Alive", "timeout=4")
|
response.Header.Set("Keep-Alive", "timeout=4")
|
||||||
response.Close = false
|
response.Close = false
|
||||||
|
} else {
|
||||||
|
response.Close = true
|
||||||
|
result = nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Trace(newError("failed to read response from ", request.Host).Base(err).AtWarning())
|
log.Trace(newError("failed to read response from ", request.Host).Base(err).AtWarning())
|
||||||
@ -270,7 +275,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
|
|||||||
return newError("connection ends").Base(err)
|
return newError("connection ends").Base(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return errWaitAnother
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user