Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
5f1d7077
Unverified
Commit
5f1d7077
authored
Mar 21, 2018
by
Will McCutchen
Committed by
GitHub
Mar 21, 2018
Browse files
Options
Downloads
Plain Diff
Merge pull request #3 from na--/deflate-fixes
Fix deflate encoded responses
parents
1a922f18
6dda7bfb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
httpbin/handlers.go
+2
-2
2 additions, 2 deletions
httpbin/handlers.go
httpbin/handlers_test.go
+5
-2
5 additions, 2 deletions
httpbin/handlers_test.go
with
7 additions
and
4 deletions
httpbin/handlers.go
+
2
−
2
View file @
5f1d7077
...
@@ -2,8 +2,8 @@ package httpbin
...
@@ -2,8 +2,8 @@ package httpbin
import
(
import
(
"bytes"
"bytes"
"compress/flate"
"compress/gzip"
"compress/gzip"
"compress/zlib"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"math/rand"
"math/rand"
...
@@ -109,7 +109,7 @@ func (h *HTTPBin) Deflate(w http.ResponseWriter, r *http.Request) {
...
@@ -109,7 +109,7 @@ func (h *HTTPBin) Deflate(w http.ResponseWriter, r *http.Request) {
body
,
_
:=
json
.
Marshal
(
resp
)
body
,
_
:=
json
.
Marshal
(
resp
)
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
w2
,
_
:=
flate
.
NewWriter
(
buf
,
flate
.
DefaultCompression
)
w2
:=
zlib
.
NewWriter
(
buf
)
w2
.
Write
(
body
)
w2
.
Write
(
body
)
w2
.
Close
()
w2
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
httpbin/handlers_test.go
+
5
−
2
View file @
5f1d7077
...
@@ -3,8 +3,8 @@ package httpbin
...
@@ -3,8 +3,8 @@ package httpbin
import
(
import
(
"bufio"
"bufio"
"bytes"
"bytes"
"compress/flate"
"compress/gzip"
"compress/gzip"
"compress/zlib"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
...
@@ -1261,7 +1261,10 @@ func TestDeflate(t *testing.T) {
...
@@ -1261,7 +1261,10 @@ func TestDeflate(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
reader
:=
flate
.
NewReader
(
w
.
Body
)
reader
,
err
:=
zlib
.
NewReader
(
w
.
Body
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
body
,
err
:=
ioutil
.
ReadAll
(
reader
)
body
,
err
:=
ioutil
.
ReadAll
(
reader
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment