MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / parseDefaultProxyHeaders

Function parseDefaultProxyHeaders

proxy_handler.go:58–71  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

56}
57
58func parseDefaultProxyHeaders(r *http.Request) string {
59 var addr string
60
61 if fwd := r.Header.Get(xForwardedForHeader); fwd != "" {
62 addr = extractFirstMatchFromIPList(fwd)
63 } else if fwd := r.Header.Get(xRealIPHeader); fwd != "" {
64 addr = extractFirstMatchFromIPList(fwd)
65 } else if fwd := r.Header.Get(forwardedHeader); fwd != "" {
66 // See: https://tools.ietf.org/html/rfc7239.
67 addr = parseForwardedHeader(fwd)
68 }
69
70 return addr
71}
72
73func extractFirstMatchFromIPList(ipList string) string {
74 if ipList == "" {

Callers 1

GetRemoteAddrMethod · 0.85

Calls 3

parseForwardedHeaderFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected