mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
[several modules] Close the response body (#1040)
This commit is contained in:
parent
a5f66588e7
commit
49109c77f7
@ -57,6 +57,8 @@ func (widget *Widget) recentBuilds(pipeline PipelineSettings) ([]Build, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ func (client *Client) finnhubRequest(symbol string) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -41,5 +41,7 @@ func (client *Client) footballRequest(path string, id int) (*http.Response, erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ func apiRequest(path, apiToken string) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -61,6 +61,7 @@ func apiRequest(path string) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -39,6 +39,7 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return view, err
|
return view, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
err = utils.ParseJSON(view, resp.Body)
|
err = utils.ParseJSON(view, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,6 +72,7 @@ func (widget *Widget) jiraRequest(path string) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -50,6 +50,7 @@ func rollbarItemRequest(accessToken, assignedToName string, activeOnly bool) (*h
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -28,6 +28,7 @@ func GetLinks(subreddit string, sortMode string, topTimePeriod string) ([]Link,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode > 299 {
|
if resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -67,6 +67,7 @@ func travisBuildRequest(settings *Settings) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
@ -158,6 +158,7 @@ func (widget *Widget) getMonitors() ([]Monitor, error) {
|
|||||||
if errh != nil {
|
if errh != nil {
|
||||||
return nil, errh
|
return nil, errh
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ func apiRequest() (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return nil, fmt.Errorf(resp.Status)
|
return nil, fmt.Errorf(resp.Status)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user