-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix some bugs that download response instead of showing result #6 #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import ( | |
"strings" | ||
"sync" | ||
|
||
"github.com/gin-gonic/gin" | ||
"gopkg.in/gin-gonic/gin.v1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are moving everything back to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so what happens if we use gin.v1 in our project ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should replace it with github.com/gin-gonic/gin. |
||
) | ||
|
||
const ( | ||
|
@@ -37,6 +37,7 @@ func Gzip(level int) gin.HandlerFunc { | |
gz.Reset(c.Writer) | ||
|
||
c.Header("Content-Encoding", "gzip") | ||
c.Header("Content-Type", "text/html; charset=UTF-8") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And how do you know that HTML should be returned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default content type is x-gizp and this encoding download the response html ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But who say that you are using gzip only for html? |
||
c.Header("Vary", "Accept-Encoding") | ||
c.Writer = &gzipWriter{c.Writer, gz} | ||
defer func() { | ||
|
@@ -70,7 +71,7 @@ func shouldCompress(req *http.Request) bool { | |
} | ||
|
||
switch extension { | ||
case ".png", ".gif", ".jpeg", ".jpg": | ||
case ".png", ".gif", ".jpeg", ".jpg", ".css", ".js": | ||
return false | ||
default: | ||
return true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work,
github.com/gin-gonic/gin
is correct.