1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-26 07:12:30 +00:00

Update vendor

This commit is contained in:
Darren Shepherd
2018-10-30 10:46:47 -07:00
parent 92a6f9ebee
commit 418b1d3d37
153 changed files with 482 additions and 12431 deletions

View File

@@ -17,6 +17,8 @@ go_test(
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",
],
)

View File

@@ -18,6 +18,7 @@ package rest
import (
"context"
"errors"
"io"
"net/http"
"net/url"
@@ -29,13 +30,14 @@ import (
)
// LocationStreamer is a resource that streams the contents of a particular
// location URL
// location URL.
type LocationStreamer struct {
Location *url.URL
Transport http.RoundTripper
ContentType string
Flush bool
ResponseChecker HttpResponseChecker
RedirectChecker func(req *http.Request, via []*http.Request) error
}
// a LocationStreamer must implement a rest.ResourceStreamer
@@ -59,7 +61,10 @@ func (s *LocationStreamer) InputStream(ctx context.Context, apiVersion, acceptHe
if transport == nil {
transport = http.DefaultTransport
}
client := &http.Client{Transport: transport}
client := &http.Client{
Transport: transport,
CheckRedirect: s.RedirectChecker,
}
req, err := http.NewRequest("GET", s.Location.String(), nil)
// Pass the parent context down to the request to ensure that the resources
// will be release properly.
@@ -87,3 +92,8 @@ func (s *LocationStreamer) InputStream(ctx context.Context, apiVersion, acceptHe
stream = resp.Body
return
}
// PreventRedirects is a redirect checker that prevents the client from following a redirect.
func PreventRedirects(_ *http.Request, _ []*http.Request) error {
return errors.New("redirects forbidden")
}