Skip to content

Commit

Permalink
fix: issue when a non HTTP request was sent after an initial CONNECT
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaidiz committed Oct 28, 2023
1 parent 474cf56 commit 48bd126
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions yves.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (p *Proxy) ServeHTTP(wrt http.ResponseWriter, req *http.Request) {
return
}

fmt.Printf("%v\n", req)
if req.Method != http.MethodConnect {
// this is a plaintext HTTP connection
reqClone := req.Clone(context.TODO())
Expand Down Expand Up @@ -130,11 +129,11 @@ func (p *Proxy) ServeHTTP(wrt http.ResponseWriter, req *http.Request) {
req, err := http.ReadRequest(clientTlsReader)
if err != nil {
log.Println("Not an HTTP request")
return
}
if isWebSocketRequest(req) {
p.serveWebsocket(wrt, req, clientConn, false)
}
return

} else {
// a TLS connection
Expand All @@ -157,12 +156,12 @@ func (p *Proxy) ServeHTTP(wrt http.ResponseWriter, req *http.Request) {
// Assume this is a HTTPS connection
//clientConnTls = p.startTlsWithClient(clientConn)
log.Println("Not an HTTP request")
return
} else {

if isWebSocketRequest(req) {
p.serveWebsocket(wrt, req, clientConn, true)
}
return
}

resp, err := p.forwardReq(ctx, req, destinationHost)
Expand Down

0 comments on commit 48bd126

Please sign in to comment.