From f6e0d08d34be25c3529e65a97cd544352a6bc087 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sat, 28 Jan 2017 23:34:55 +0100 Subject: [PATCH] Fix HTTP proxy --- app/proxyman/outbound/handler.go | 4 ++-- proxy/http/server.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 112790b8c..bbe49202f 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -2,7 +2,6 @@ package outbound import ( "context" - "errors" "io" "net" "time" @@ -10,6 +9,7 @@ import ( "v2ray.com/core/app" "v2ray.com/core/app/proxyman" "v2ray.com/core/common/buf" + "v2ray.com/core/common/errors" "v2ray.com/core/common/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/proxy" @@ -67,7 +67,7 @@ func (h *Handler) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) { ctx = proxy.ContextWithDialer(ctx, h) err := h.proxy.Process(ctx, outboundRay) // Ensure outbound ray is properly closed. - if err != nil { + if err != nil && errors.Cause(err) != io.EOF { outboundRay.OutboundOutput().CloseError() } else { outboundRay.OutboundOutput().Close() diff --git a/proxy/http/server.go b/proxy/http/server.go index dccb4e38d..608c09257 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -213,10 +213,9 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea ray := s.packetDispatcher.DispatchToOutbound(ctx) input := ray.InboundInput() output := ray.InboundOutput() + defer input.Close() requestDone := signal.ExecuteAsync(func() error { - defer input.Close() - requestWriter := bufio.NewWriter(buf.NewBytesWriter(ray.InboundInput())) err := request.Write(requestWriter) if err != nil {