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:
parent
221453d622
commit
f7bf82368a
|
|
@ -122,6 +122,9 @@ func Req(fileName string) (*ocsp.Response, error) {
|
||||||
http.DefaultClient.Timeout = 5 * time.Second
|
http.DefaultClient.Timeout = 5 * time.Second
|
||||||
|
|
||||||
httpResp, err := sendHTTPRequest(req, ocspURL)
|
httpResp, err := sendHTTPRequest(req, ocspURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
fmt.Printf("HTTP %d\n", httpResp.StatusCode)
|
fmt.Printf("HTTP %d\n", httpResp.StatusCode)
|
||||||
for k, v := range httpResp.Header {
|
for k, v := range httpResp.Header {
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue