Merge pull request #25332 from wojtek-t/fix_protobuf_failures

Fix protobuf failures
This commit is contained in:
Wojciech Tyczynski
2016-05-09 10:23:20 +02:00
2 changed files with 29 additions and 6 deletions

View File

@@ -648,6 +648,7 @@ func (r *Request) Watch() (watch.Interface, error) {
if err != nil {
return nil, err
}
req.Header = r.headers
client := r.client
if client == nil {
client = http.DefaultClient
@@ -715,6 +716,7 @@ func (r *Request) Stream() (io.ReadCloser, error) {
if err != nil {
return nil, err
}
req.Header = r.headers
client := r.client
if client == nil {
client = http.DefaultClient

View File

@@ -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) {
original := Request{
err: errors.New("test"),
@@ -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) {
testCases := []struct {
Request *Request