refactor: use splitn in header parser

This commit is contained in:
Stavros
2025-06-15 19:55:03 +03:00
parent aeb93da378
commit a621135ac0

View File

@@ -181,12 +181,14 @@ func ParseHeaders(headers []string) map[string]string {
// Loop through the headers // Loop through the headers
for _, header := range headers { for _, header := range headers {
headerSplit := strings.Split(header, "=") split := strings.SplitN(header, "=", 2)
if len(headerSplit) != 2 { if len(split) != 2 {
log.Warn().Str("header", header).Msg("Invalid header format, skipping") log.Warn().Str("header", header).Msg("Invalid header format, skipping")
continue continue
} }
headerMap[headerSplit[0]] = SanitizeHeader(headerSplit[1]) key := SanitizeHeader(strings.TrimSpace(split[0]))
value := SanitizeHeader(strings.TrimSpace(split[1]))
headerMap[key] = value
} }
// Return the header map // Return the header map