fix http_proxy support GET
This commit is contained in:
parent
a51e221db3
commit
8e76acdda3
@ -74,8 +74,8 @@ func (hp *HTTPProxy) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBuf
|
|||||||
wrapConn.Close()
|
wrapConn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if strings.Index(strings.ToUpper(string(firstBytes)), "CONNECT") == 0 ||
|
||||||
if strings.ToUpper(string(firstBytes)) == "CONNECT" {
|
strings.Index(strings.ToUpper(string(firstBytes)), "GET") == 0 {
|
||||||
bufRd := bufio.NewReader(sc)
|
bufRd := bufio.NewReader(sc)
|
||||||
request, err := http.ReadRequest(bufRd)
|
request, err := http.ReadRequest(bufRd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -192,7 +192,11 @@ func (hp *HTTPProxy) handleConnectReq(req *http.Request, rwc io.ReadWriteCloser)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
remote, err := net.Dial("tcp", req.URL.Host)
|
dialHost := req.URL.Host
|
||||||
|
if !strings.Contains(dialHost, ":") {
|
||||||
|
dialHost = dialHost + ":http"
|
||||||
|
}
|
||||||
|
remote, err := net.Dial("tcp", dialHost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res := &http.Response{
|
res := &http.Response{
|
||||||
StatusCode: 400,
|
StatusCode: 400,
|
||||||
@ -203,8 +207,11 @@ func (hp *HTTPProxy) handleConnectReq(req *http.Request, rwc io.ReadWriteCloser)
|
|||||||
res.Write(rwc)
|
res.Write(rwc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.Method == "GET" {
|
||||||
|
req.Write(remote)
|
||||||
|
} else {
|
||||||
rwc.Write([]byte("HTTP/1.1 200 OK\r\n\r\n"))
|
rwc.Write([]byte("HTTP/1.1 200 OK\r\n\r\n"))
|
||||||
|
}
|
||||||
frpIo.Join(remote, rwc)
|
frpIo.Join(remote, rwc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user