MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / parseForwardedHeaders

Function parseForwardedHeaders

pkg/webmiddleware/proxy_headers.go:123–145  ·  view source on GitHub ↗
(h http.Header)

Source from the content-addressed store, hash-verified

121}
122
123func parseForwardedHeaders(h http.Header) (forwardedFor, forwardedScheme, forwardedHost string) {
124 if xForwardedFor := h.Get(headerXForwardedFor); xForwardedFor != "" {
125 forwardedFor = xForwardedFor
126 }
127 if xForwardedProto := h.Get(headerXForwardedProto); xForwardedProto != "" {
128 forwardedScheme = xForwardedProto
129 }
130 if xForwardedHost := h.Get(headerXForwardedHost); xForwardedHost != "" {
131 forwardedHost = xForwardedHost
132 }
133 if forwarded := h.Get(headerForwarded); forwarded != "" {
134 if match := forwardedForRegex.FindStringSubmatch(forwarded); len(match) > 1 {
135 forwardedFor = strings.ToLower(match[1])
136 }
137 if match := forwardedProtoRegex.FindStringSubmatch(forwarded); len(match) > 1 {
138 forwardedScheme = strings.ToLower(match[1])
139 }
140 if match := forwardedHostRegex.FindStringSubmatch(forwarded); len(match) > 1 {
141 forwardedHost = strings.ToLower(match[1])
142 }
143 }
144 return forwardedFor, forwardedScheme, forwardedHost
145}

Callers 1

ProxyHeadersFunction · 0.70

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected