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
()
| 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. |
| 510 | func (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. |