Skip to content

Commit

Permalink
Reverting httpsEndpoint for using https_port
Browse files Browse the repository at this point in the history
  • Loading branch information
telepenin committed Jan 17, 2023
1 parent c51a5f3 commit 875b681
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/http_api/api_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -120,7 +121,7 @@ retry:

func httpsEndpoint(endpoint string, body []byte) (string, error) {
var forbiddenResp struct {
HTTPSAddr string `json:"https_addr"`
HTTPSPort int `json:"https_port"`
}
err := json.Unmarshal(body, &forbiddenResp)
if err != nil {
Expand All @@ -132,7 +133,12 @@ func httpsEndpoint(endpoint string, body []byte) (string, error) {
return "", err
}

host, _, err := net.SplitHostPort(u.Host)
if err != nil {
return "", err
}

u.Scheme = "https"
u.Host = forbiddenResp.HTTPSAddr
u.Host = net.JoinHostPort(host, strconv.Itoa(forbiddenResp.HTTPSPort))
return u.String(), nil
}

0 comments on commit 875b681

Please sign in to comment.