Merge pull request #2400 from influxdb/client-write-credentials-2391

Always send auth headers for client requests if present
pull/2404/head v0.9.0-rc27
Cory LaNou 2015-04-22 20:38:36 -06:00
commit c887dfe2a8
2 changed files with 14 additions and 2 deletions

View File

@ -13,6 +13,8 @@
- [#2386](https://github.com/influxdb/influxdb/pull/2386): Fix shard datanodes stats getting appended too many times
- [#2393](https://github.com/influxdb/influxdb/pull/2393): Fix default hostname for connecting to cluster.
- [#2390](https://github.com/influxdb/influxdb/pull/2393): Handle large sums when calculating means - thanks @neonstalwart!
- [#2391](https://github.com/influxdb/influxdb/pull/2391): Unable to write points through Go client when authentication enabled
- [#2400](https://github.com/influxdb/influxdb/pull/2400): Always send auth headers for client requests if present
## v0.9.0-rc26 [04-21-2015]

View File

@ -122,6 +122,10 @@ func (c *Client) Write(bp BatchPoints) (*Response, error) {
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", c.userAgent)
if c.username != "" {
req.SetBasicAuth(c.username, c.password)
}
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, err
@ -155,6 +159,10 @@ func (c *Client) Ping() (time.Duration, string, error) {
return 0, "", err
}
req.Header.Set("User-Agent", c.userAgent)
if c.username != "" {
req.SetBasicAuth(c.username, c.password)
}
resp, err := c.httpClient.Do(req)
if err != nil {
return 0, "", err
@ -170,8 +178,6 @@ func (c *Client) Dump(db string) (io.ReadCloser, error) {
u.Path = "dump"
values := u.Query()
values.Set("db", db)
values.Set("user", c.username)
values.Set("password", c.password)
u.RawQuery = values.Encode()
req, err := http.NewRequest("GET", u.String(), nil)
@ -179,6 +185,10 @@ func (c *Client) Dump(db string) (io.ReadCloser, error) {
return nil, err
}
req.Header.Set("User-Agent", c.userAgent)
if c.username != "" {
req.SetBasicAuth(c.username, c.password)
}
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, err