Skip to content

Commit

Permalink
Cloud: set gzip value to Content-Encoding header
Browse files Browse the repository at this point in the history
  • Loading branch information
ppcano committed Jan 15, 2018
1 parent dddbc05 commit 9cc576a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions stats/cloud/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ func (c *Client) CreateTestRun(testRun *TestRun) (*CreateTestRunResponse, error)
func (c *Client) PushMetric(referenceID string, compress bool, samples []*Sample) error {
url := fmt.Sprintf("%s/metrics/%s", c.baseURL, referenceID)

var req *http.Request
var reqError error

if compress {
var buf bytes.Buffer
if samples != nil {
Expand All @@ -106,14 +103,19 @@ func (c *Client) PushMetric(referenceID string, compress bool, samples []*Sample
return err
}
}
req, reqError = http.NewRequest("POST", url, &buf)
req, err := http.NewRequest("POST", url, &buf)
if err != nil {
return err
}
req.Header.Set("Content-Encoding", "gzip")
return c.Do(req, nil)
} else {
req, reqError = c.NewRequest("POST", url, samples)
}
if reqError != nil {
return reqError
req, err := c.NewRequest("POST", url, samples)
if err != nil {
return err
}
return c.Do(req, nil)
}
return c.Do(req, nil)
}

func (c *Client) StartCloudTestRun(name string, arc *lib.Archive) (string, error) {
Expand Down

0 comments on commit 9cc576a

Please sign in to comment.