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

Function Test_Ctx_Scheme_UnTrustedProxy

ctx_test.go:5038–5063  ·  view source on GitHub ↗

go test -run Test_Ctx_Scheme_UnTrustedProxy

(t *testing.T)

Source from the content-addressed store, hash-verified

5036
5037// go test -run Test_Ctx_Scheme_UnTrustedProxy
5038func Test_Ctx_Scheme_UnTrustedProxy(t *testing.T) {
5039 t.Parallel()
5040 app := New(Config{
5041 TrustProxy: true,
5042 TrustProxyConfig: TrustProxyConfig{Proxies: []string{"0.8.0.1"}},
5043 })
5044 c := app.AcquireCtx(&fasthttp.RequestCtx{})
5045
5046 c.Request().Header.Set(HeaderXForwardedProto, schemeHTTPS)
5047 require.Equal(t, schemeHTTP, c.Scheme())
5048 c.Request().Header.Reset()
5049
5050 c.Request().Header.Set(HeaderXForwardedProtocol, schemeHTTPS)
5051 require.Equal(t, schemeHTTP, c.Scheme())
5052 c.Request().Header.Reset()
5053
5054 c.Request().Header.Set(HeaderXForwardedSsl, "on")
5055 require.Equal(t, schemeHTTP, c.Scheme())
5056 c.Request().Header.Reset()
5057
5058 c.Request().Header.Set(HeaderXUrlScheme, schemeHTTPS)
5059 require.Equal(t, schemeHTTP, c.Scheme())
5060 c.Request().Header.Reset()
5061
5062 require.Equal(t, schemeHTTP, c.Scheme())
5063}
5064
5065// go test -run Test_Ctx_Query
5066func Test_Ctx_Query(t *testing.T) {

Callers

nothing calls this directly

Calls 6

AcquireCtxMethod · 0.80
NewFunction · 0.70
SetMethod · 0.65
RequestMethod · 0.65
SchemeMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected