1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

Fix HTTP proxy

This commit is contained in:
Darien Raymond 2017-01-28 23:34:55 +01:00
parent c09ca41161
commit f6e0d08d34
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 3 additions and 4 deletions

View File

@ -2,7 +2,6 @@ package outbound
import ( import (
"context" "context"
"errors"
"io" "io"
"net" "net"
"time" "time"
@ -10,6 +9,7 @@ import (
"v2ray.com/core/app" "v2ray.com/core/app"
"v2ray.com/core/app/proxyman" "v2ray.com/core/app/proxyman"
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/log" "v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy" "v2ray.com/core/proxy"
@ -67,7 +67,7 @@ func (h *Handler) Dispatch(ctx context.Context, outboundRay ray.OutboundRay) {
ctx = proxy.ContextWithDialer(ctx, h) ctx = proxy.ContextWithDialer(ctx, h)
err := h.proxy.Process(ctx, outboundRay) err := h.proxy.Process(ctx, outboundRay)
// Ensure outbound ray is properly closed. // Ensure outbound ray is properly closed.
if err != nil { if err != nil && errors.Cause(err) != io.EOF {
outboundRay.OutboundOutput().CloseError() outboundRay.OutboundOutput().CloseError()
} else { } else {
outboundRay.OutboundOutput().Close() outboundRay.OutboundOutput().Close()

View File

@ -213,10 +213,9 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, rea
ray := s.packetDispatcher.DispatchToOutbound(ctx) ray := s.packetDispatcher.DispatchToOutbound(ctx)
input := ray.InboundInput() input := ray.InboundInput()
output := ray.InboundOutput() output := ray.InboundOutput()
defer input.Close()
requestDone := signal.ExecuteAsync(func() error { requestDone := signal.ExecuteAsync(func() error {
defer input.Close()
requestWriter := bufio.NewWriter(buf.NewBytesWriter(ray.InboundInput())) requestWriter := bufio.NewWriter(buf.NewBytesWriter(ray.InboundInput()))
err := request.Write(requestWriter) err := request.Write(requestWriter)
if err != nil { if err != nil {