Skip to content

Commit 3beb18f

Browse files
committed
feat(serverHandler): output HSTS header only for TLS connection
1 parent 98d3c60 commit 3beb18f

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/serverHandler/hsts.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@ import (
66
)
77

88
func (h *aliasHandler) tryHsts(w http.ResponseWriter, r *http.Request) (needRedirect bool) {
9-
_, port := util.ExtractHostnamePort(r.Host)
10-
11-
if len(port) > 0 {
12-
return
13-
}
14-
15-
header := w.Header()
16-
header.Set("Strict-Transport-Security", "max-age="+h.hstsMaxAge)
17-
189
if r.TLS != nil {
10+
w.Header().Set("Strict-Transport-Security", "max-age="+h.hstsMaxAge)
1911
return
2012
}
2113

0 commit comments

Comments
 (0)