MCPcopy
hub / github.com/gofiber/fiber / Host

Method Host

req.go:510–520  ·  view source on GitHub ↗

Host contains the host derived from the X-Forwarded-Host or Host HTTP header. Returned value is only valid within the handler. Do not store any references. In a network context, `Host` refers to the combination of a hostname and potentially a port number used for connecting, while `Hostname` refers

()

Source from the content-addressed store, hash-verified

508// Make copies or use the Immutable setting instead.
509// Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
510func (r *DefaultReq) Host() string {
511 if r.IsProxyTrusted() {
512 if host := r.Get(HeaderXForwardedHost); host != "" {
513 if before, _, found := strings.Cut(host, ","); found {
514 return utils.TrimSpace(before)
515 }
516 return utils.TrimSpace(host)
517 }
518 }
519 return r.c.app.toString(r.c.fasthttp.Request.URI().Host())
520}
521
522// Hostname contains the hostname derived from the X-Forwarded-Host or Host HTTP header using the c.Host() method.
523// Returned value is only valid within the handler. Do not store any references.

Callers 1

HostnameMethod · 0.95

Calls 5

IsProxyTrustedMethod · 0.95
GetMethod · 0.95
toStringMethod · 0.80
URIMethod · 0.80
HostMethod · 0.65

Tested by

no test coverage detected