Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
ae2e0900
Commit
ae2e0900
authored
Nov 13, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #339 from cubicdaiya/vary-accept-encoding
gzip: added Vary: Accept-Encoding to response header.
parents
fc6afe2a
69662d4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
middleware/gzip/gzip.go
middleware/gzip/gzip.go
+1
-0
middleware/gzip/gzip_test.go
middleware/gzip/gzip_test.go
+3
-0
No files found.
middleware/gzip/gzip.go
View file @
ae2e0900
...
...
@@ -47,6 +47,7 @@ outer:
r
.
Header
.
Del
(
"Accept-Encoding"
)
w
.
Header
()
.
Set
(
"Content-Encoding"
,
"gzip"
)
w
.
Header
()
.
Set
(
"Vary"
,
"Accept-Encoding"
)
gzipWriter
,
err
:=
newWriter
(
c
,
w
)
if
err
!=
nil
{
// should not happen
...
...
middleware/gzip/gzip_test.go
View file @
ae2e0900
...
...
@@ -87,6 +87,9 @@ func nextFunc(shouldGzip bool) middleware.Handler {
if
w
.
Header
()
.
Get
(
"Content-Encoding"
)
!=
"gzip"
{
return
0
,
fmt
.
Errorf
(
"Content-Encoding must be gzip, found %v"
,
r
.
Header
.
Get
(
"Content-Encoding"
))
}
if
w
.
Header
()
.
Get
(
"Vary"
)
!=
"Accept-Encoding"
{
return
0
,
fmt
.
Errorf
(
"Vary must be Accept-Encoding, found %v"
,
r
.
Header
.
Get
(
"Vary"
))
}
if
_
,
ok
:=
w
.
(
gzipResponseWriter
);
!
ok
{
return
0
,
fmt
.
Errorf
(
"ResponseWriter should be gzipResponseWriter, found %T"
,
w
)
}
...
...
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