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

Function Test_Ctx_Hostname_TrustedProxy

ctx_test.go:3130–3143  ·  view source on GitHub ↗

go test -run Test_Ctx_Hostname_Trusted

(t *testing.T)

Source from the content-addressed store, hash-verified

3128
3129// go test -run Test_Ctx_Hostname_Trusted
3130func Test_Ctx_Hostname_TrustedProxy(t *testing.T) {
3131 t.Parallel()
3132 {
3133 app := New(Config{
3134 TrustProxy: true,
3135 TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.0.0.0", "0.8.0.1"}},
3136 })
3137 c := app.AcquireCtx(&fasthttp.RequestCtx{})
3138 c.Request().SetRequestURI("http://google.com/test")
3139 c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
3140 require.Equal(t, "google1.com", c.Hostname())
3141 app.ReleaseCtx(c)
3142 }
3143}
3144
3145// go test -run Test_Ctx_Hostname_Trusted_Multiple
3146func Test_Ctx_Hostname_TrustedProxy_Multiple(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
SetMethod · 0.65
HostnameMethod · 0.65

Tested by

no test coverage detected