Merge pull request #79673 from cheftako/bugFix

Making sure we handle error on http.NewRequest() in streamer
This commit is contained in:
Kubernetes Prow Robot 2019-07-08 16:00:02 -07:00 committed by GitHub
commit 13c07e5327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ package rest
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"net/url"
@ -66,6 +67,9 @@ func (s *LocationStreamer) InputStream(ctx context.Context, apiVersion, acceptHe
CheckRedirect: s.RedirectChecker,
}
req, err := http.NewRequest("GET", s.Location.String(), nil)
if err != nil {
return nil, false, "", fmt.Errorf("failed to construct request for %s, got %v", s.Location.String(), err)
}
// Pass the parent context down to the request to ensure that the resources
// will be release properly.
req = req.WithContext(ctx)