header analyzer fix large headers

This commit is contained in:
nahakubuilde
2025-07-18 07:33:11 +01:00
parent 597ddef66f
commit 20cfcd1829
13 changed files with 8166 additions and 165 deletions
+17
View File
@@ -4,12 +4,18 @@ import (
"embed"
"html/template"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"headeranalyzer/security"
)
type Handler struct {
templates *template.Template
csrf *security.CSRFManager
validator *security.InputValidator
}
type PasswordConfig struct {
@@ -57,10 +63,19 @@ func NewHandler(embeddedFiles embed.FS) *Handler {
return &Handler{
templates: tmpl,
csrf: security.NewCSRFManager(time.Hour),
validator: security.NewInputValidator(),
}
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Generate CSRF token
csrfToken, err := h.csrf.GenerateToken()
if err != nil {
http.Redirect(w, r, "/password?error="+url.QueryEscape("Security token generation failed"), http.StatusSeeOther)
return
}
// Parse URL parameters to set default values
config := PasswordConfig{
Type: getStringParam(r, "type", "passphrase"),
@@ -80,9 +95,11 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
data := struct {
CurrentPage string
Config PasswordConfig
CSRFToken string
}{
CurrentPage: "password",
Config: config,
CSRFToken: csrfToken,
}
h.templates.ExecuteTemplate(w, "password.html", data)
}