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

Function Test_Ctx_Host_UntrustedProxyRange

ctx_test.go:2951–2960  ·  view source on GitHub ↗

go test -run Test_Ctx_Host_UntrustedProxyRange

(t *testing.T)

Source from the content-addressed store, hash-verified

2949
2950// go test -run Test_Ctx_Host_UntrustedProxyRange
2951func Test_Ctx_Host_UntrustedProxyRange(t *testing.T) {
2952 t.Parallel()
2953
2954 app := New(Config{TrustProxy: true, TrustProxyConfig: TrustProxyConfig{Proxies: []string{"1.0.0.0/30"}}})
2955 c := app.AcquireCtx(&fasthttp.RequestCtx{})
2956 c.Request().SetRequestURI("http://google.com/test")
2957 c.Request().Header.Set(HeaderXForwardedHost, "google1.com")
2958 require.Equal(t, "google.com", c.Host())
2959 app.ReleaseCtx(c)
2960}
2961
2962// go test -v -run=^$ -bench=Benchmark_Ctx_Host -benchmem -count=4
2963func Benchmark_Ctx_Host(b *testing.B) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected