Skip to content

Commit

Permalink
Merging to release-4-lts: [TT-8547] Fix websocket error proxying (#4918)
Browse files Browse the repository at this point in the history
[TT-8547] Fix websocket error proxying  (#4918)

## Description

Upgrade websocket only when server responded with 101. 
Fixes the case when websocket have own authentification, so we can proxy
this error.

## Motivation and Context

<!-- Why is this change required? What problem does it solve? -->

## How This Has Been Tested

<!-- Please describe in detail how you tested your changes -->
<!-- Include details of your testing environment, and the tests -->
<!-- you ran to see how your change affects other areas of the code,
etc. -->
<!-- This information is helpful for reviewers and QA. -->

## Screenshots (if appropriate)

## Types of changes

<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test
coverage to functionality)

## Checklist

<!-- Go over all the following points, and put an `x` in all the boxes
that apply -->
<!-- If there are no documentation updates required, mark the item as
checked. -->
<!-- Raise up any additional concerns not covered by the checklist. -->

- [ ] I ensured that the documentation is up to date
- [ ] I explained why this PR updates go.mod in detail with reasoning
why it's required
- [ ] I would like a code coverage CI quality gate exception and have
explained why
  • Loading branch information
buger authored Nov 6, 2023
1 parent 2988f8b commit 4234213
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gateway/reverse_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ func (p *ReverseProxy) WrappedServeHTTP(rw http.ResponseWriter, req *http.Reques

upgrade, _ := p.IsUpgrade(req)
// Deal with 101 Switching Protocols responses: (WebSocket, h2c, etc)
if upgrade {
if upgrade && res.StatusCode == 101 {
if err := p.handleUpgradeResponse(rw, outreq, res); err != nil {
p.ErrorHandler.HandleError(rw, logreq, err.Error(), http.StatusInternalServerError, true)
return ProxyResponse{UpstreamLatency: upstreamLatency}
Expand Down

0 comments on commit 4234213

Please sign in to comment.