MCPcopy
hub / github.com/caddyserver/caddy / getHeaderFieldVals

Function getHeaderFieldVals

modules/caddyhttp/matchers.go:1027–1036  ·  view source on GitHub ↗

getHeaderFieldVals returns the field values for the given fieldName from input. The host parameter should be obtained from the http.Request.Host field, and the transferEncoding from http.Request.TransferEncoding, since net/http removes them from the header map.

(input http.Header, fieldName, host string, transferEncoding []string)

Source from the content-addressed store, hash-verified

1025// transferEncoding from http.Request.TransferEncoding, since net/http removes them
1026// from the header map.
1027func getHeaderFieldVals(input http.Header, fieldName, host string, transferEncoding []string) []string {
1028 fieldName = textproto.CanonicalMIMEHeaderKey(fieldName)
1029 if fieldName == "Host" && host != "" {
1030 return []string{host}
1031 }
1032 if fieldName == "Transfer-Encoding" && input[fieldName] == nil {
1033 return transferEncoding
1034 }
1035 return input[fieldName]
1036}
1037
1038// matchHeaders returns true if input matches the criteria in against without regex.
1039// The host parameter should be obtained from the http.Request.Host field since

Callers 2

matchHeadersFunction · 0.85
MatchWithErrorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected