diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b54785698244..78825e30831db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## v0.11.1 [unreleased] + +### Features + +### Bugfixes +- [#852](https://github.com/influxdata/telegraf/issues/852): Windows zip package fix +- [#859](https://github.com/influxdata/telegraf/issues/859): httpjson plugin panic + ## v0.11.0 [2016-03-15] ### Release Notes diff --git a/plugins/inputs/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go index 0619958929dcd..6fe4da1e54263 100644 --- a/plugins/inputs/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -55,15 +55,15 @@ type RealHTTPClient struct { client *http.Client } -func (c RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { +func (c *RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { return c.client.Do(req) } -func (c RealHTTPClient) SetHTTPClient(client *http.Client) { +func (c *RealHTTPClient) SetHTTPClient(client *http.Client) { c.client = client } -func (c RealHTTPClient) HTTPClient() *http.Client { +func (c *RealHTTPClient) HTTPClient() *http.Client { return c.client } @@ -289,6 +289,8 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) { func init() { inputs.Add("httpjson", func() telegraf.Input { - return &HttpJson{client: RealHTTPClient{}} + return &HttpJson{ + client: &RealHTTPClient{}, + } }) } diff --git a/plugins/inputs/httpjson/httpjson_test.go b/plugins/inputs/httpjson/httpjson_test.go index 1a1187d443395..31447b307176f 100644 --- a/plugins/inputs/httpjson/httpjson_test.go +++ b/plugins/inputs/httpjson/httpjson_test.go @@ -125,7 +125,7 @@ type mockHTTPClient struct { // Mock implementation of MakeRequest. Usually returns an http.Response with // hard-coded responseBody and statusCode. However, if the request uses a // nonstandard method, it uses status code 405 (method not allowed) -func (c mockHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { +func (c *mockHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { resp := http.Response{} resp.StatusCode = c.statusCode @@ -147,10 +147,10 @@ func (c mockHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) { return &resp, nil } -func (c mockHTTPClient) SetHTTPClient(_ *http.Client) { +func (c *mockHTTPClient) SetHTTPClient(_ *http.Client) { } -func (c mockHTTPClient) HTTPClient() *http.Client { +func (c *mockHTTPClient) HTTPClient() *http.Client { return nil } @@ -164,7 +164,7 @@ func (c mockHTTPClient) HTTPClient() *http.Client { func genMockHttpJson(response string, statusCode int) []*HttpJson { return []*HttpJson{ &HttpJson{ - client: mockHTTPClient{responseBody: response, statusCode: statusCode}, + client: &mockHTTPClient{responseBody: response, statusCode: statusCode}, Servers: []string{ "http://server1.example.com/metrics/", "http://server2.example.com/metrics/", @@ -181,7 +181,7 @@ func genMockHttpJson(response string, statusCode int) []*HttpJson { }, }, &HttpJson{ - client: mockHTTPClient{responseBody: response, statusCode: statusCode}, + client: &mockHTTPClient{responseBody: response, statusCode: statusCode}, Servers: []string{ "http://server3.example.com/metrics/", "http://server4.example.com/metrics/", @@ -241,7 +241,7 @@ func TestHttpJsonGET_URL(t *testing.T) { Servers: []string{ts.URL + "?api_key=mykey"}, Name: "", Method: "GET", - client: RealHTTPClient{client: &http.Client{}}, + client: &RealHTTPClient{client: &http.Client{}}, } var acc testutil.Accumulator @@ -314,7 +314,7 @@ func TestHttpJsonGET(t *testing.T) { Name: "", Method: "GET", Parameters: params, - client: RealHTTPClient{client: &http.Client{}}, + client: &RealHTTPClient{client: &http.Client{}}, } var acc testutil.Accumulator @@ -388,7 +388,7 @@ func TestHttpJsonPOST(t *testing.T) { Name: "", Method: "POST", Parameters: params, - client: RealHTTPClient{client: &http.Client{}}, + client: &RealHTTPClient{client: &http.Client{}}, } var acc testutil.Accumulator