mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-15 10:04:02 +02:00
fix(middleware): set Accept-Encoding to "" in modify_html middleware
This commit is contained in:
parent
e3b53a548d
commit
b6bfd19cc2
1 changed files with 6 additions and 0 deletions
|
@ -20,6 +20,11 @@ type modifyHTML struct {
|
||||||
|
|
||||||
var ModifyHTML = NewMiddleware[modifyHTML]()
|
var ModifyHTML = NewMiddleware[modifyHTML]()
|
||||||
|
|
||||||
|
func (m *modifyHTML) before(w http.ResponseWriter, req *http.Request) bool {
|
||||||
|
req.Header.Set("Accept-Encoding", "")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// modifyResponse implements ResponseModifier.
|
// modifyResponse implements ResponseModifier.
|
||||||
func (m *modifyHTML) modifyResponse(resp *http.Response) error {
|
func (m *modifyHTML) modifyResponse(resp *http.Response) error {
|
||||||
// including text/html and application/xhtml+xml
|
// including text/html and application/xhtml+xml
|
||||||
|
@ -63,6 +68,7 @@ func (m *modifyHTML) modifyResponse(resp *http.Response) error {
|
||||||
}
|
}
|
||||||
resp.ContentLength = int64(len(h))
|
resp.ContentLength = int64(len(h))
|
||||||
resp.Header.Set("Content-Length", strconv.Itoa(len(h)))
|
resp.Header.Set("Content-Length", strconv.Itoa(len(h)))
|
||||||
|
resp.Header.Set("Content-Type", "text/html; charset=utf-8")
|
||||||
resp.Body = io.NopCloser(bytes.NewReader(h))
|
resp.Body = io.NopCloser(bytes.NewReader(h))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue