Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
1103e9ef
Unverified
Commit
1103e9ef
authored
5 years ago
by
Drew Bailey
Browse files
Options
Download
Email Patches
Plain Diff
un-gzip if content encoding header present
parent
057b8715
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/allocations_test.go
+2
-1
api/allocations_test.go
api/api.go
+13
-1
api/api.go
with
15 additions
and
2 deletions
+15
-2
api/allocations_test.go
+
2
-
1
View file @
1103e9ef
...
...
@@ -297,7 +297,8 @@ func TestAllocations_ExecErrors(t *testing.T) {
// make a request that will result in an error
// ensure the error is what we expect
_
,
err
:=
a
.
Exec
(
context
.
Background
(),
alloc
,
"bar"
,
false
,
[]
string
{
"command"
},
os
.
Stdin
,
os
.
Stdout
,
os
.
Stderr
,
sizeCh
,
nil
)
require
.
Equal
(
t
,
err
.
Error
(),
"Unexpected response code: 301"
)
require
.
Contains
(
t
,
err
.
Error
(),
"Unexpected response code: 301"
)
require
.
Contains
(
t
,
err
.
Error
(),
"Moved Permanently"
)
}
func
TestAllocations_ShouldMigrate
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
api/api.go
+
13
-
1
View file @
1103e9ef
...
...
@@ -741,8 +741,20 @@ func (c *Client) websocket(endpoint string, q *QueryOptions) (*websocket.Conn, *
// check resp status code, as it's more informative than handshake error we get from ws library
if
resp
!=
nil
&&
resp
.
StatusCode
!=
101
{
var
buf
bytes
.
Buffer
if
resp
.
Header
.
Get
(
"Content-Encoding"
)
==
"gzip"
{
greader
,
err
:=
gzip
.
NewReader
(
resp
.
Body
)
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"Unexpected response code: %d"
,
resp
.
StatusCode
)
}
io
.
Copy
(
&
buf
,
greader
)
}
else
{
io
.
Copy
(
&
buf
,
resp
.
Body
)
}
resp
.
Body
.
Close
()
return
nil
,
nil
,
fmt
.
Errorf
(
"Unexpected response code: %d"
,
resp
.
StatusCode
)
return
nil
,
nil
,
fmt
.
Errorf
(
"Unexpected response code: %d (%s)"
,
resp
.
StatusCode
,
buf
.
Bytes
())
}
return
conn
,
resp
,
err
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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