Dont do auth on service worker index page requests
This commit is contained in:
parent
fd6c8a70e2
commit
f86e0d9283
@ -261,7 +261,36 @@ func (d *Dispatch) serveFiles(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) {
|
func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
state := d.handleAuth(w, r, false)
|
if pusher, ok := w.(http.Pusher); ok {
|
||||||
|
options := &http.PushOptions{
|
||||||
|
Header: http.Header{
|
||||||
|
"Accept-Encoding": r.Header["Accept-Encoding"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cookie, err := r.Cookie("push")
|
||||||
|
if err != nil {
|
||||||
|
for _, asset := range h2PushAssets {
|
||||||
|
pusher.Push(asset.path, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
setPushCookie(w, r)
|
||||||
|
} else {
|
||||||
|
pushed := false
|
||||||
|
|
||||||
|
for i, asset := range h2PushAssets {
|
||||||
|
if len(cookie.Value) >= (i+1)*8 &&
|
||||||
|
asset.hash != cookie.Value[i*8:(i+1)*8] {
|
||||||
|
pusher.Push(asset.path, options)
|
||||||
|
pushed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if pushed {
|
||||||
|
setPushCookie(w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, sw := r.URL.Query()["sw"]
|
_, sw := r.URL.Query()["sw"]
|
||||||
|
|
||||||
@ -291,44 +320,11 @@ func (d *Dispatch) serveIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Strict-Transport-Security", hstsHeader)
|
w.Header().Set("Strict-Transport-Security", hstsHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pusher, ok := w.(http.Pusher); ok {
|
|
||||||
options := &http.PushOptions{
|
|
||||||
Header: http.Header{
|
|
||||||
"Accept-Encoding": r.Header["Accept-Encoding"],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cookie, err := r.Cookie("push")
|
|
||||||
if err != nil {
|
|
||||||
for _, asset := range h2PushAssets {
|
|
||||||
pusher.Push(asset.path, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
setPushCookie(w, r)
|
|
||||||
} else {
|
|
||||||
pushed := false
|
|
||||||
|
|
||||||
for i, asset := range h2PushAssets {
|
|
||||||
if len(cookie.Value) >= (i+1)*8 &&
|
|
||||||
asset.hash != cookie.Value[i*8:(i+1)*8] {
|
|
||||||
pusher.Push(asset.path, options)
|
|
||||||
pushed = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if pushed {
|
|
||||||
setPushCookie(w, r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var data *indexData
|
var data *indexData
|
||||||
|
inline := inlineScriptSW
|
||||||
if !sw {
|
if !sw {
|
||||||
data = getIndexData(r, r.URL.EscapedPath(), state)
|
data = getIndexData(r, r.URL.EscapedPath(), d.handleAuth(w, r, false))
|
||||||
}
|
inline = inlineScript
|
||||||
|
|
||||||
inline := inlineScript
|
|
||||||
if sw {
|
|
||||||
inline = inlineScriptSW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||||
|
Loading…
Reference in New Issue
Block a user