MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / applyHeaders

Function applyHeaders

auth/rejectstatic.go:78–106  ·  view source on GitHub ↗
(r io.Reader, h http.Header)

Source from the content-addressed store, hash-verified

76}
77
78func applyHeaders(r io.Reader, h http.Header) error {
79 scanner := bufio.NewScanner(r)
80 for scanner.Scan() {
81 line := scanner.Bytes()
82 name, value, found := bytes.Cut(line, []byte{':'})
83 if found {
84 value = bytes.TrimLeft(value, " \t")
85 if len(value) == 0 {
86 // Explicitly disabled header
87 h[string(name)] = nil
88 } else {
89 // Normal header value
90 h[string(name)] = append(h[string(name)], string(value))
91 }
92 } else {
93 name, _, found := bytes.Cut(line, []byte{';'})
94 if found {
95 // send a header with an empty value
96 h[string(name)] = append(h[string(name)], "")
97 } else {
98 return fmt.Errorf("malformed header line %q", string(line))
99 }
100 }
101 }
102 if err := scanner.Err(); err != nil {
103 return fmt.Errorf("header parsing failed: %w", err)
104 }
105 return nil
106}
107
108func (_ *StaticRejectAuth) Valid(_, _, _ string) bool {
109 return false

Callers 1

ValidateMethod · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected