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
c8fe00b9
Commit
c8fe00b9
authored
Nov 03, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16711 from liggitt/remotecommand_error
Auto commit by PR queue bot
parents
121f3306
ddae7491
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
remotecommand.go
pkg/client/unversioned/remotecommand/remotecommand.go
+0
-4
roundtripper.go
pkg/util/httpstream/spdy/roundtripper.go
+1
-1
roundtripper_test.go
pkg/util/httpstream/spdy/roundtripper_test.go
+15
-1
No files found.
pkg/client/unversioned/remotecommand/remotecommand.go
View file @
c8fe00b9
...
@@ -130,10 +130,6 @@ func (e *streamExecutor) Dial(protocols ...string) (httpstream.Connection, strin
...
@@ -130,10 +130,6 @@ func (e *streamExecutor) Dial(protocols ...string) (httpstream.Connection, strin
}
}
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
http
.
StatusSwitchingProtocols
{
return
nil
,
""
,
fmt
.
Errorf
(
"unexpected response status code %d (%s)"
,
resp
.
StatusCode
,
http
.
StatusText
(
resp
.
StatusCode
))
}
conn
,
err
:=
e
.
upgrader
.
NewConnection
(
resp
)
conn
,
err
:=
e
.
upgrader
.
NewConnection
(
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
""
,
err
return
nil
,
""
,
err
...
...
pkg/util/httpstream/spdy/roundtripper.go
View file @
c8fe00b9
...
@@ -205,7 +205,7 @@ func (s *SpdyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
...
@@ -205,7 +205,7 @@ func (s *SpdyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
func
(
s
*
SpdyRoundTripper
)
NewConnection
(
resp
*
http
.
Response
)
(
httpstream
.
Connection
,
error
)
{
func
(
s
*
SpdyRoundTripper
)
NewConnection
(
resp
*
http
.
Response
)
(
httpstream
.
Connection
,
error
)
{
connectionHeader
:=
strings
.
ToLower
(
resp
.
Header
.
Get
(
httpstream
.
HeaderConnection
))
connectionHeader
:=
strings
.
ToLower
(
resp
.
Header
.
Get
(
httpstream
.
HeaderConnection
))
upgradeHeader
:=
strings
.
ToLower
(
resp
.
Header
.
Get
(
httpstream
.
HeaderUpgrade
))
upgradeHeader
:=
strings
.
ToLower
(
resp
.
Header
.
Get
(
httpstream
.
HeaderUpgrade
))
if
!
strings
.
Contains
(
connectionHeader
,
strings
.
ToLower
(
httpstream
.
HeaderUpgrade
))
||
!
strings
.
Contains
(
upgradeHeader
,
strings
.
ToLower
(
HeaderSpdy31
))
{
if
(
resp
.
StatusCode
!=
http
.
StatusSwitchingProtocols
)
||
!
strings
.
Contains
(
connectionHeader
,
strings
.
ToLower
(
httpstream
.
HeaderUpgrade
))
||
!
strings
.
Contains
(
upgradeHeader
,
strings
.
ToLower
(
HeaderSpdy31
))
{
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
responseError
:=
""
responseError
:=
""
responseErrorBytes
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
responseErrorBytes
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
...
...
pkg/util/httpstream/spdy/roundtripper_test.go
View file @
c8fe00b9
...
@@ -39,30 +39,42 @@ func TestRoundTripAndNewConnection(t *testing.T) {
...
@@ -39,30 +39,42 @@ func TestRoundTripAndNewConnection(t *testing.T) {
clientTLS
*
tls
.
Config
clientTLS
*
tls
.
Config
serverConnectionHeader
string
serverConnectionHeader
string
serverUpgradeHeader
string
serverUpgradeHeader
string
serverStatusCode
int
shouldError
bool
shouldError
bool
}{
}{
"no headers"
:
{
"no headers"
:
{
serverFunc
:
httptest
.
NewServer
,
serverFunc
:
httptest
.
NewServer
,
serverConnectionHeader
:
""
,
serverConnectionHeader
:
""
,
serverUpgradeHeader
:
""
,
serverUpgradeHeader
:
""
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
true
,
shouldError
:
true
,
},
},
"no upgrade header"
:
{
"no upgrade header"
:
{
serverFunc
:
httptest
.
NewServer
,
serverFunc
:
httptest
.
NewServer
,
serverConnectionHeader
:
"Upgrade"
,
serverConnectionHeader
:
"Upgrade"
,
serverUpgradeHeader
:
""
,
serverUpgradeHeader
:
""
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
true
,
shouldError
:
true
,
},
},
"no connection header"
:
{
"no connection header"
:
{
serverFunc
:
httptest
.
NewServer
,
serverFunc
:
httptest
.
NewServer
,
serverConnectionHeader
:
""
,
serverConnectionHeader
:
""
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
true
,
},
"no switching protocol status code"
:
{
serverFunc
:
httptest
.
NewServer
,
serverConnectionHeader
:
"Upgrade"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverStatusCode
:
http
.
StatusForbidden
,
shouldError
:
true
,
shouldError
:
true
,
},
},
"http"
:
{
"http"
:
{
serverFunc
:
httptest
.
NewServer
,
serverFunc
:
httptest
.
NewServer
,
serverConnectionHeader
:
"Upgrade"
,
serverConnectionHeader
:
"Upgrade"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
false
,
shouldError
:
false
,
},
},
"https (invalid hostname + InsecureSkipVerify)"
:
{
"https (invalid hostname + InsecureSkipVerify)"
:
{
...
@@ -81,6 +93,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
...
@@ -81,6 +93,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
clientTLS
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
clientTLS
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
serverConnectionHeader
:
"Upgrade"
,
serverConnectionHeader
:
"Upgrade"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
false
,
shouldError
:
false
,
},
},
"https (valid hostname + RootCAs)"
:
{
"https (valid hostname + RootCAs)"
:
{
...
@@ -99,6 +112,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
...
@@ -99,6 +112,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
clientTLS
:
&
tls
.
Config
{
RootCAs
:
localhostPool
},
clientTLS
:
&
tls
.
Config
{
RootCAs
:
localhostPool
},
serverConnectionHeader
:
"Upgrade"
,
serverConnectionHeader
:
"Upgrade"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverUpgradeHeader
:
"SPDY/3.1"
,
serverStatusCode
:
http
.
StatusSwitchingProtocols
,
shouldError
:
false
,
shouldError
:
false
,
},
},
}
}
...
@@ -112,7 +126,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
...
@@ -112,7 +126,7 @@ func TestRoundTripAndNewConnection(t *testing.T) {
w
.
Header
()
.
Set
(
httpstream
.
HeaderConnection
,
testCase
.
serverConnectionHeader
)
w
.
Header
()
.
Set
(
httpstream
.
HeaderConnection
,
testCase
.
serverConnectionHeader
)
w
.
Header
()
.
Set
(
httpstream
.
HeaderUpgrade
,
testCase
.
serverUpgradeHeader
)
w
.
Header
()
.
Set
(
httpstream
.
HeaderUpgrade
,
testCase
.
serverUpgradeHeader
)
w
.
WriteHeader
(
http
.
StatusSwitchingProtocols
)
w
.
WriteHeader
(
testCase
.
serverStatusCode
)
return
return
}
}
...
...
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