Fix: HTTP inbound leak
This commit is contained in:
parent
f375f080da
commit
3f3db8476e
1 changed files with 1 additions and 9 deletions
|
@ -29,9 +29,9 @@ func handleHTTP(ctx *context.HTTPContext, outbound net.Conn) {
|
||||||
for {
|
for {
|
||||||
keepAlive := strings.TrimSpace(strings.ToLower(req.Header.Get("Proxy-Connection"))) == "keep-alive"
|
keepAlive := strings.TrimSpace(strings.ToLower(req.Header.Get("Proxy-Connection"))) == "keep-alive"
|
||||||
|
|
||||||
req.Header.Set("Connection", "close")
|
|
||||||
req.RequestURI = ""
|
req.RequestURI = ""
|
||||||
inbound.RemoveHopByHopHeaders(req.Header)
|
inbound.RemoveHopByHopHeaders(req.Header)
|
||||||
|
req.Header.Set("Connection", "close")
|
||||||
err := req.Write(outbound)
|
err := req.Write(outbound)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
@ -72,14 +72,6 @@ func handleHTTP(ctx *context.HTTPContext, outbound net.Conn) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// even if resp.Write write body to the connection, but some http request have to Copy to close it
|
|
||||||
buf := pool.Get(pool.RelayBufferSize)
|
|
||||||
_, err = io.CopyBuffer(conn, resp.Body, buf)
|
|
||||||
pool.Put(buf)
|
|
||||||
if err != nil && err != io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err = http.ReadRequest(inboundReader)
|
req, err = http.ReadRequest(inboundReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue