Skip to content

Commit

Permalink
Fix negative resp.TotalTime() (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Feb 22, 2023
1 parent 67b393b commit be24aaa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion response.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ func (r *Response) TotalTime() time.Duration {
if r.Request.trace != nil {
return r.Request.TraceInfo().TotalTime
}
return r.receivedAt.Sub(r.Request.StartTime)
if !r.receivedAt.IsZero() {
return r.receivedAt.Sub(r.Request.StartTime)
}
return r.Request.responseReturnTime.Sub(r.Request.StartTime)
}

// ReceivedAt returns the timestamp that response we received.
Expand Down

0 comments on commit be24aaa

Please sign in to comment.