优化HTTP2、HTTP跳转

This commit is contained in:
刘祥超
2023-04-07 15:09:06 +08:00
parent 6da9cb6dcf
commit 7db0c8cf62
2 changed files with 11 additions and 9 deletions

View File

@@ -208,3 +208,13 @@ func httpAcceptEncoding(acceptEncodings string, encoding string) bool {
}
return false
}
// 跳转到某个URL
func httpRedirect(writer http.ResponseWriter, req *http.Request, url string, code int) {
if len(writer.Header().Get("Content-Type")) == 0 {
// 设置Content-Type是为了让页面不输出链接
writer.Header().Set("Content-Type", "text/html; charset=utf-8")
}
http.Redirect(writer, req, url, code)
}