Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
[代理]websocket请求没有使用服务器的RequestURI
Browse files Browse the repository at this point in the history
  • Loading branch information
guo_b3 committed Dec 8, 2020
1 parent 397d6b4 commit b749f0e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions internal/teaproxy/request_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ func (this *Request) callWebsocket(writer *ResponseWriter) error {
host = this.Format(this.backend.Host)
}

if this.backend.HasRequestURI() {
uri := this.Format(this.backend.RequestPath())
u, err := url.ParseRequestURI(uri)
if err == nil {
this.raw.URL.Path = CleanPath(u.Path)
this.raw.URL.RawQuery = u.RawQuery

args := this.Format(this.backend.RequestArgs())
if len(args) > 0 {
if len(u.RawQuery) > 0 {
this.raw.URL.RawQuery += "&" + args
} else {
this.raw.URL.RawQuery += args
}
}
}
} else {
u, err := url.ParseRequestURI(this.uri)
if err == nil {
this.raw.URL.Path = u.Path
this.raw.URL.RawQuery = u.RawQuery
}
}

wsURL := url.URL{
Scheme: scheme,
Host: host,
Expand Down

0 comments on commit b749f0e

Please sign in to comment.