From 20a3c231de6b5b04964144fd4a757bb8b27d85a5 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Tue, 12 Jun 2018 22:43:34 +0800 Subject: [PATCH] Fixed: https proxy doesn't works in Safari --- proxy/http.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/proxy/http.go b/proxy/http.go index 617430b..6251223 100644 --- a/proxy/http.go +++ b/proxy/http.go @@ -3,7 +3,6 @@ package proxy import ( "bufio" "bytes" - "crypto/tls" "fmt" "io" "net" @@ -27,8 +26,6 @@ func NewHttpProxy(port string) { handleHTTP(w, r) } }), - // Disable HTTP/2. - TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), } log.Infof("HTTP proxy :%s", port) server.ListenAndServe() @@ -53,7 +50,6 @@ func handleHTTP(w http.ResponseWriter, r *http.Request) { } func handleTunneling(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) hijacker, ok := w.(http.Hijacker) if !ok { return @@ -62,13 +58,14 @@ func handleTunneling(w http.ResponseWriter, r *http.Request) { if err != nil { return } + // w.WriteHeader(http.StatusOK) doesn't works in Safari + conn.Write([]byte("HTTP/1.1 200 OK\r\n\r\n")) tun.Add(NewHttp(r.Host, conn, rw, []byte{})) } type HttpAdapter struct { addr *constant.Addr conn net.Conn - rw *bufio.ReadWriter r io.Reader } @@ -115,7 +112,6 @@ func NewHttp(host string, conn net.Conn, rw *bufio.ReadWriter, payload []byte) * return &HttpAdapter{ conn: conn, addr: parseHttpAddr(host), - rw: rw, r: r, } }