Skip to content

Commit

Permalink
Merge pull request influxdata#2400 from influxdb/client-write-credent…
Browse files Browse the repository at this point in the history
…ials-2391

Always send auth headers for client requests if present
  • Loading branch information
corylanou committed Apr 23, 2015
2 parents 0bc0f8d + bba66f6 commit c887dfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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]

Expand Down
14 changes: 12 additions & 2 deletions client/influxdb.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -170,15 +178,17 @@ 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)
if err != nil {
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
Expand Down

0 comments on commit c887dfe

Please sign in to comment.