Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a7be41d4
Commit
a7be41d4
authored
May 09, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25332 from wojtek-t/fix_protobuf_failures
Fix protobuf failures
parents
06e2a354
1ea0d46b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
request.go
pkg/client/restclient/request.go
+2
-0
request_test.go
pkg/client/restclient/request_test.go
+27
-6
No files found.
pkg/client/restclient/request.go
View file @
a7be41d4
...
@@ -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
...
...
pkg/client/restclient/request_test.go
View file @
a7be41d4
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment