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

Function Test_Ctx_Hostname_UntrustedProxyRange

ctx_test.go:3177–3189  ·  view source on GitHub ↗

go test -run Test_Ctx_Hostname_UntrustedProxyRange

(t *testing.T)

Source from the content-addressed store, hash-verified

3175
3176// go test -run Test_Ctx_Hostname_UntrustedProxyRange
3177func Test_Ctx_Hostname_UntrustedProxyRange(t *testing.T) {
3178 t.Parallel()
3179
3180 app := New(Config{
3181 TrustProxy: true,
3182 TrustProxyConfig: TrustProxyConfig{Proxies: []string{"1.0.0.0/30"}},
3183 })
3184 c := app.AcquireCtx(&fasthttp.RequestCtx{})
3185 c.Request().SetRequestURI("http://google.com/test")
3186 c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
3187 require.Equal(t, "google.com", c.Hostname())
3188 app.ReleaseCtx(c)
3189}
3190
3191// go test -run Test_Ctx_Port
3192func Test_Ctx_Port(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