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/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -52,7 +53,7 @@ func jsonRPCSend(user string, password string, server string, message []byte,
|
|||
client.Transport = transport
|
||||
protocol = "https"
|
||||
}
|
||||
credentials := user + ":" + password
|
||||
credentials := url.UserPassword(user, password).String()
|
||||
resp, err := client.Post(protocol+"://"+credentials+"@"+server,
|
||||
"application/json", bytes.NewReader(message))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue