Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions util/httputils/httputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ func GetAddrPort(urlStr string) (string, int, error) {
return "", 0, err
}
host := parts.Host
commaPos := strings.IndexByte(host, ':')
if commaPos > 0 {
port, err := strconv.ParseInt(host[commaPos+1:], 10, 32)
hostAddr, hostPortStr, err := net.SplitHostPort(host)
if err == nil {
hostPort, err := strconv.ParseInt(hostPortStr, 10, 32)
if err != nil {
return "", 0, err
return "", 0, errors.Wrapf(err, "strconv.ParseInt port string %s", hostPortStr)
} else {
return host[:commaPos], int(port), nil
return hostAddr, int(hostPort), nil
}
} else {
switch parts.Scheme {
Expand All @@ -299,7 +299,7 @@ func GetAddrPort(urlStr string) (string, int, error) {
case "https":
return parts.Host, 443, nil
default:
return "", 0, fmt.Errorf("Unknown schema %s", parts.Scheme)
return "", 0, errors.Wrapf(errors.ErrInvalidFormat, "Unknown schema %s", parts.Scheme)
}
}
}
Expand Down Expand Up @@ -515,7 +515,7 @@ func request(client sClient, ctx context.Context, method THttpMethod, urlStr str
var reqBody string
if bodySeeker, ok := body.(io.ReadSeeker); ok {
bodySeeker.Seek(0, io.SeekStart)
reqBodyBytes, _ := ioutil.ReadAll(bodySeeker)
reqBodyBytes, _ := io.ReadAll(bodySeeker)
if reqBodyBytes != nil {
reqBody = string(reqBodyBytes)
}
Expand Down