Login form with 200 and no cache header

This commit is contained in:
Jan-Lukas Else 2021-02-27 09:05:39 +01:00
parent e25199b2a3
commit 6de2ae6ff3
2 changed files with 5 additions and 2 deletions

View File

@ -42,7 +42,8 @@ func authMiddleware(next http.Handler) http.Handler {
return
}
// 3. Show login form
w.WriteHeader(http.StatusUnauthorized)
w.WriteHeader(http.StatusOK)
w.Header().Set("Cache-Control", "no-cache,no-store,must-revalidate")
h, _ := json.Marshal(r.Header.Clone())
b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte
_ = r.Body.Close()

View File

@ -178,7 +178,9 @@ func getCache(key string, next http.Handler, r *http.Request) (item *cacheItem)
body: body,
}
// Save cache
cacheLru.Add(key, item)
if cch := item.header.Get("Cache-Control"); !strings.Contains(cch, "no-store") && !strings.Contains(cch, "private") && !strings.Contains(cch, "no-cache") {
cacheLru.Add(key, item)
}
}
return item
}