Fixed: https proxy doesn't works in Safari
This commit is contained in:
parent
b5f24c56b2
commit
cc515d0269
1 changed files with 2 additions and 6 deletions
|
@ -3,7 +3,6 @@ package proxy
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
@ -27,8 +26,6 @@ func NewHttpProxy(port string) {
|
||||||
handleHTTP(w, r)
|
handleHTTP(w, r)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// Disable HTTP/2.
|
|
||||||
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
|
|
||||||
}
|
}
|
||||||
log.Infof("HTTP proxy :%s", port)
|
log.Infof("HTTP proxy :%s", port)
|
||||||
server.ListenAndServe()
|
server.ListenAndServe()
|
||||||
|
@ -53,7 +50,6 @@ func handleHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleTunneling(w http.ResponseWriter, r *http.Request) {
|
func handleTunneling(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
hijacker, ok := w.(http.Hijacker)
|
hijacker, ok := w.(http.Hijacker)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
@ -62,13 +58,14 @@ func handleTunneling(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
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{}))
|
tun.Add(NewHttp(r.Host, conn, rw, []byte{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
type HttpAdapter struct {
|
type HttpAdapter struct {
|
||||||
addr *constant.Addr
|
addr *constant.Addr
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
rw *bufio.ReadWriter
|
|
||||||
r io.Reader
|
r io.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +112,6 @@ func NewHttp(host string, conn net.Conn, rw *bufio.ReadWriter, payload []byte) *
|
||||||
return &HttpAdapter{
|
return &HttpAdapter{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
addr: parseHttpAddr(host),
|
addr: parseHttpAddr(host),
|
||||||
rw: rw,
|
|
||||||
r: r,
|
r: r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue