Skip to content

Commit

Permalink
Merge pull request #187 from dillondrobena/master
Browse files Browse the repository at this point in the history
Use negotiateVersion from query parameter if present
  • Loading branch information
philippseith authored Dec 14, 2023
2 parents fcfe993 + bec82c7 commit d7c816a
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 d7c816a

Please sign in to comment.