Skip to content

Commit

Permalink
Use negotiateVersion from query parameter if present
Browse files Browse the repository at this point in the history
  • Loading branch information
dillondrobena committed Dec 12, 2023
1 parent fcfe993 commit bec82c7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions httpmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,25 @@ func (h *httpMux) negotiate(w http.ResponseWriter, req *http.Request) {
} else {
connectionID := newConnectionID()
connectionMapKey := connectionID
negotiateVersion, err := strconv.Atoi(req.Header.Get("negotiateVersion"))

// Check the header for negotiateVersion
headerNegotiateVersion, err := strconv.Atoi(req.Header.Get("negotiateVersion"))
if err != nil {
headerNegotiateVersion = 0
}

// Check the query parameter for negotiateVersion
queryNegotiateVersion, err := strconv.Atoi(req.URL.Query().Get("negotiateVersion"))
if err != nil {
negotiateVersion = 0
queryNegotiateVersion = 0
}

// Use the negotiateVersion from query if present, otherwise use the one from the header parameter
negotiateVersion := queryNegotiateVersion
if headerNegotiateVersion != 0 {
negotiateVersion = headerNegotiateVersion
}

connectionToken := ""
if negotiateVersion == 1 {
connectionToken = newConnectionID()
Expand Down

0 comments on commit bec82c7

Please sign in to comment.