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:
Dave Collins 2014-09-20 19:05:38 -05:00
parent 1caddd4a37
commit a5b1a31e07

View file

@ -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 {