Skip to content

Commit

Permalink
Use the net package function for credentials.
Browse files Browse the repository at this point in the history
This change ensures any usernames or passwords which contain symbols that
would confuse the URL parser are properly escaped.
  • Loading branch information
davecgh committed Sep 21, 2014
1 parent 1caddd4 commit a5b1a31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jsonfxns.go
Expand Up @@ -15,6 +15,7 @@ import (
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a5b1a31

Please sign in to comment.