From cc077f6fb0e7e7532810bc9fe8321fdbd9382afb Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 6 Nov 2015 11:12:40 -0700 Subject: [PATCH] Create a new query request for each Query --- client/v2/client.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/v2/client.go b/client/v2/client.go index 1550bea8fb..a908b06c17 100644 --- a/client/v2/client.go +++ b/client/v2/client.go @@ -335,9 +335,6 @@ func (uc *udpclient) Write(bp BatchPoints) error { } func (c *client) Write(bp BatchPoints) error { - u := c.url - u.Path = "write" - var b bytes.Buffer for _, p := range bp.Points() { @@ -350,6 +347,8 @@ func (c *client) Write(bp BatchPoints) error { } } + u := c.url + u.Path = "write" req, err := http.NewRequest("POST", u.String(), &b) if err != nil { return err @@ -426,25 +425,26 @@ func (uc *udpclient) Query(q Query) (*Response, error) { // Query sends a command to the server and returns the Response func (c *client) Query(q Query) (*Response, error) { u := c.url - u.Path = "query" - values := u.Query() - values.Set("q", q.Command) - values.Set("db", q.Database) - if q.Precision != "" { - values.Set("epoch", q.Precision) - } - u.RawQuery = values.Encode() req, err := http.NewRequest("GET", u.String(), nil) if err != nil { return nil, err } + req.Header.Set("Content-Type", "") req.Header.Set("User-Agent", c.useragent) if c.username != "" { req.SetBasicAuth(c.username, c.password) } + params := req.URL.Query() + params.Set("q", q.Command) + params.Set("db", q.Database) + if q.Precision != "" { + params.Set("epoch", q.Precision) + } + req.URL.RawQuery = params.Encode() + resp, err := c.httpClient.Do(req) if err != nil { return nil, err