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
Łukasz Nowak
caddy
Commits
1b17072a
Commit
1b17072a
authored
Apr 26, 2015
by
Thomas Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gzip middleware now strips encoding header
parent
7d46108c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+6
-12
middleware/gzip/gzip.go
middleware/gzip/gzip.go
+1
-0
No files found.
middleware/fastcgi/fastcgi.go
View file @
1b17072a
...
...
@@ -5,9 +5,7 @@ package fastcgi
import
(
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
...
...
@@ -105,11 +103,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
}
w
.
WriteHeader
(
resp
.
StatusCode
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
fmt
.
Printf
(
"%s"
,
b
ody
)
fmt
.
Printf
(
"%d
\n
"
,
resp
.
StatusCode
)
fmt
.
Printf
(
"%d
\n
"
,
len
(
body
))
w
.
Write
(
body
)
// Write the response body
_
,
err
=
io
.
Copy
(
w
,
resp
.
B
ody
)
if
err
!=
nil
{
return
http
.
StatusBadGateway
,
err
}
return
resp
.
StatusCode
,
nil
}
...
...
@@ -196,12 +194,8 @@ func (h Handler) buildEnv(r *http.Request, rule Rule) (map[string]string, error)
for
field
,
val
:=
range
r
.
Header
{
header
:=
strings
.
ToUpper
(
field
)
header
=
headerNameReplacer
.
Replace
(
header
)
// We don't want to pass the encoding header to prevent the fastcgi server from gzipping
// TODO: is there a better way.
if
header
!=
"ACCEPT_ENCODING"
{
env
[
"HTTP_"
+
header
]
=
strings
.
Join
(
val
,
", "
)
}
}
return
env
,
nil
}
...
...
middleware/gzip/gzip.go
View file @
1b17072a
...
...
@@ -33,6 +33,7 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
return
g
.
Next
.
ServeHTTP
(
w
,
r
)
}
r
.
Header
.
Del
(
"Accept-Encoding"
)
w
.
Header
()
.
Set
(
"Content-Encoding"
,
"gzip"
)
gzipWriter
:=
gzip
.
NewWriter
(
w
)
defer
gzipWriter
.
Close
()
...
...
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