Use the net package function for credentials.
This change ensures any usernames or passwords which contain symbols that would confuse the URL parser are properly escaped.
This commit is contained in:
parent
1caddd4a37
commit
a5b1a31e07
1 changed files with 2 additions and 1 deletions
|
@ -15,6 +15,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ func jsonRPCSend(user string, password string, server string, message []byte,
|
||||||
client.Transport = transport
|
client.Transport = transport
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
}
|
}
|
||||||
credentials := user + ":" + password
|
credentials := url.UserPassword(user, password).String()
|
||||||
resp, err := client.Post(protocol+"://"+credentials+"@"+server,
|
resp, err := client.Post(protocol+"://"+credentials+"@"+server,
|
||||||
"application/json", bytes.NewReader(message))
|
"application/json", bytes.NewReader(message))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue