Allow username:password to be included with host

This commit is contained in:
Paul Bonser 2017-03-02 19:02:12 -06:00
parent 429a615005
commit d7fb602e0f
2 changed files with 6 additions and 1 deletions

View File

@ -582,7 +582,7 @@ func (c *Client) AliasExists(alias string) (bool, error) {
}
func (c *Client) replaceHost(req *http.Request) {
req.URL.User = c.Host.User
req.URL.Scheme = c.Host.Scheme
req.URL.Host = c.Host.Host
}

View File

@ -44,6 +44,11 @@ func (s *GoesTestSuite) TestNewClient(c *C) {
c.Assert(conn, DeepEquals, &Client{&url.URL{Scheme: "http", Host: ESHost + ":" + ESPort}, http.DefaultClient, ""})
}
func (s *GoesTestSuite) TestNewClientWithAuth(c *C) {
conn := NewClient("foo:bar@"+ESHost, ESPort)
c.Assert(conn, DeepEquals, &Client{&url.URL{Scheme: "http", User: url.UserPassword("foo", "bar"), Host: ESHost + ":" + ESPort}, http.DefaultClient, ""})
}
func (s *GoesTestSuite) TestWithHTTPClient(c *C) {
tr := &http.Transport{
DisableCompression: true,