Return error from `sendHTTPRequest` immediately. (#2925)

Prior to this commit the `httpResp` result of `sendHTTPRequest` was
examined even in the case where `sendHTTPRequest` returns a non-nil
error. This can cause a nil panic since the `httpResp` may be `nil` when
the error is not. This commit returns an error from `Req()` immediately
when `sendHTTPRequest` returns one.
This commit is contained in:
Daniel McCarney 2017-07-31 14:19:03 -04:00 committed by Jacob Hoffman-Andrews
parent 221453d622
commit f7bf82368a
1 changed files with 3 additions and 0 deletions

View File

@ -122,6 +122,9 @@ func Req(fileName string) (*ocsp.Response, error) {
http.DefaultClient.Timeout = 5 * time.Second
httpResp, err := sendHTTPRequest(req, ocspURL)
if err != nil {
return nil, err
}
fmt.Printf("HTTP %d\n", httpResp.StatusCode)
for k, v := range httpResp.Header {
for _, vv := range v {