1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

close connection when content length unknown

This commit is contained in:
Darien Raymond 2017-04-18 14:18:09 +02:00
parent 18904e9adb
commit 9db86e871e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -221,6 +221,8 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
output := ray.InboundOutput()
defer input.Close()
var result error = errWaitAnother
requestDone := signal.ExecuteAsync(func() error {
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("Keep-Alive", "timeout=4")
response.Close = false
} else {
response.Close = true
result = nil
}
} else {
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 errWaitAnother
return result
}
func init() {