Commit a7be41d4 authored by Wojciech Tyczynski's avatar Wojciech Tyczynski

Merge pull request #25332 from wojtek-t/fix_protobuf_failures

Fix protobuf failures
parents 06e2a354 1ea0d46b
...@@ -648,6 +648,7 @@ func (r *Request) Watch() (watch.Interface, error) { ...@@ -648,6 +648,7 @@ func (r *Request) Watch() (watch.Interface, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header = r.headers
client := r.client client := r.client
if client == nil { if client == nil {
client = http.DefaultClient client = http.DefaultClient
...@@ -715,6 +716,7 @@ func (r *Request) Stream() (io.ReadCloser, error) { ...@@ -715,6 +716,7 @@ func (r *Request) Stream() (io.ReadCloser, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header = r.headers
client := r.client client := r.client
if client == nil { if client == nil {
client = http.DefaultClient client = http.DefaultClient
......
...@@ -58,6 +58,33 @@ func TestNewRequestSetsAccept(t *testing.T) { ...@@ -58,6 +58,33 @@ func TestNewRequestSetsAccept(t *testing.T) {
} }
} }
type clientFunc func(req *http.Request) (*http.Response, error)
func (f clientFunc) Do(req *http.Request) (*http.Response, error) {
return f(req)
}
func TestRequestSetsHeaders(t *testing.T) {
server := clientFunc(func(req *http.Request) (*http.Response, error) {
if req.Header.Get("Accept") != "application/other, */*" {
t.Errorf("unexpected headers: %#v", req.Header)
}
return &http.Response{
StatusCode: http.StatusForbidden,
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}, nil
})
config := defaultContentConfig()
config.ContentType = "application/other"
serializers := defaultSerializers()
r := NewRequest(server, "get", &url.URL{Path: "/path"}, "", config, serializers, nil, nil)
// Check if all "issue" methods are setting headers.
_ = r.Do()
_, _ = r.Watch()
_, _ = r.Stream()
}
func TestRequestWithErrorWontChange(t *testing.T) { func TestRequestWithErrorWontChange(t *testing.T) {
original := Request{ original := Request{
err: errors.New("test"), err: errors.New("test"),
...@@ -463,12 +490,6 @@ func TestTransformUnstructuredError(t *testing.T) { ...@@ -463,12 +490,6 @@ func TestTransformUnstructuredError(t *testing.T) {
} }
} }
type clientFunc func(req *http.Request) (*http.Response, error)
func (f clientFunc) Do(req *http.Request) (*http.Response, error) {
return f(req)
}
func TestRequestWatch(t *testing.T) { func TestRequestWatch(t *testing.T) {
testCases := []struct { testCases := []struct {
Request *Request Request *Request
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment