MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / validateHeader

Function validateHeader

pkg/validation/header.go:20–40  ·  view source on GitHub ↗
(header options.Header, names map[string]struct{})

Source from the content-addressed store, hash-verified

18}
19
20func validateHeader(header options.Header, names map[string]struct{}) []string {
21 msgs := []string{}
22
23 if header.Name == "" {
24 msgs = append(msgs, "header has empty name: names are required for all headers")
25 }
26
27 if _, ok := names[header.Name]; ok {
28 msgs = append(msgs, fmt.Sprintf("multiple headers found with name %q: header names must be unique", header.Name))
29 }
30 names[header.Name] = struct{}{}
31
32 for _, value := range header.Values {
33 msgs = append(msgs,
34 prefixValues(fmt.Sprintf("invalid header %q: invalid values: ", header.Name),
35 validateHeaderValue(header.Name, value)...,
36 )...,
37 )
38 }
39 return msgs
40}
41
42func validateHeaderValue(_ string, value options.HeaderValue) []string {
43 switch {

Callers 1

validateHeadersFunction · 0.85

Calls 2

prefixValuesFunction · 0.85
validateHeaderValueFunction · 0.85

Tested by

no test coverage detected