mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Making sure we handle error on http.NewRequest().
http.NewRequest can return an error. (Eg. error parsing url). This will cause us to have a nil req object. That in turn will become a SIGSEGV when we set the context.
This commit is contained in:
parent
03291ca467
commit
ee2ad1d1fe
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user