Skip to content

Commit f8419d3

Browse files
committed
http代理debug
1 parent 79cf8cb commit f8419d3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

session/httpProxy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ func (sm *SessionsManager) GetAllHTTP(ctx context.Context, in *pb.Device) (*pb.H
125125
func (sm *SessionsManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
126126
//:TODO 当前不支持websocket的代理(websocket支持basic Auth),或者从beego分发?
127127
//:TODO 非80端口r.Host的支持情况
128-
//log.Printf("host:" + r.Host) //"http://127.0.0.1:8080/"
128+
log.Println("host:", r.Host)
129+
log.Println("hostRequestURI:", r.RequestURI)
130+
if r.TLS != nil {
131+
log.Println("是https请求")
132+
} else {
133+
log.Println("是http请求")
134+
}
129135
hostInfo, err := sm.GetOneHttpProxy(strings.Split(r.Host, ":")[0])
130136
if err != nil {
131137
_, _ = w.Write([]byte(err.Error()))
@@ -138,7 +144,8 @@ func (sm *SessionsManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
138144
}
139145
}
140146

141-
remote, err := url.Parse(fmt.Sprintf("http://%s/", r.Host))
147+
var remote *url.URL
148+
remote, err = url.Parse(fmt.Sprintf("%s://%s/", r.Proto, r.Host))
142149
if err != nil {
143150
log.Printf(err.Error())
144151
w.Write([]byte(err.Error()))

0 commit comments

Comments
 (0)