Skip to content

Commit

Permalink
Issue #159: Panic on invalid response
Browse files Browse the repository at this point in the history
The metered roundtripper is not checking whether the
response is valid before registering the status code.
This leads to a panic on that handler. This patch
fixes this behavior.
  • Loading branch information
magiconair committed Sep 11, 2016
1 parent da13970 commit 17a7cfe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ type meteredRoundTripper struct {
func (m *meteredRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
start := time.Now()
resp, err := m.tr.RoundTrip(r)
metrics.DefaultRegistry.GetTimer(name(resp.StatusCode)).UpdateSince(start)
if resp != nil {
metrics.DefaultRegistry.GetTimer(name(resp.StatusCode)).UpdateSince(start)
}
return resp, err
}

Expand Down

0 comments on commit 17a7cfe

Please sign in to comment.