Skip to content

Commit

Permalink
don't close resp.Body if POST fails
Browse files Browse the repository at this point in the history
when http.Post fails, resp.Body.Close seems to cause a hard crash on the
entire process
  • Loading branch information
sputnik13 committed Apr 20, 2017
1 parent e7dd714 commit 177dc64
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions http_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type HTTPPostNode struct {
bp *bufpool.Pool
}

// Create a new HTTPPostNode which caches the most recent item and exposes it over the HTTP API.
// Create a new HTTPPostNode which submits received items via POST to an HTTP endpoint
func newHTTPPostNode(et *ExecutingTask, n *pipeline.HTTPPostNode, l *log.Logger) (*HTTPPostNode, error) {
hn := &HTTPPostNode{
node: node{Node: n, et: et, logger: l},
Expand Down Expand Up @@ -79,6 +79,7 @@ func (h *HTTPPostNode) postRow(group models.GroupID, row *models.Row) {
resp, err := http.Post(h.url, "application/json", body)
if err != nil {
h.logger.Printf("E! failed to POST row data: %v", err)
} else {
resp.Body.Close()
}
resp.Body.Close()
}

0 comments on commit 177dc64

Please sign in to comment.