Move set above rewrite to fix uninitialized variable #5211
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
Moved set default_connection_header above rewrites to fix a warning in the logs about that variable being uninitialized.
I did extensive testing before making this change to make sure this won't affect anyone. Using my own web socket app and the
examples/custom-resources/traffic-splitting/cafe-virtual-server.yaml
in the issue to test what changes are made if I moved this set before the rewrites.Doing a websocket connecton via
npx wscat -c ws://cafe.example.com:80
does not give a warning which means it's only curl giving the warningCurl hasn't recognised websockets due to curl being designed for standard http only and therefore gives the warning as http_upgrade is blank doing a curl and not using websockets as websockets automatically sets the upgrade and connection headers. That is why there is a warning.
Doing the websocket connection defines the http_upgrade which then maps the default_connection_header so therefore it is defined and initialised so it doesn't give the warning.
This curl command doesn't give a warning before and after moving the set so therefore everything will work as normal, this change will just mask the warning
curl --include \ --header "Connection: Upgrade" \ --header "Upgrade: websocket" \ http://cafe.example.com:80/
Resolves: #5082
Checklist
Before creating a PR, run through this checklist and mark each as complete.