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

Function Test_Ctx_FullURL_DoesNotAliasPooledBuffer

ctx_test.go:264–286  ·  view source on GitHub ↗

go test -run Test_Ctx_FullURL_DoesNotAliasPooledBuffer

(t *testing.T)

Source from the content-addressed store, hash-verified

262
263// go test -run Test_Ctx_FullURL_DoesNotAliasPooledBuffer
264func Test_Ctx_FullURL_DoesNotAliasPooledBuffer(t *testing.T) {
265 t.Parallel()
266
267 const bufferPoolReuseAttempts = 128
268
269 app := New()
270 c := app.AcquireCtx(&fasthttp.RequestCtx{})
271
272 c.Request().Header.SetHost("example.com")
273 c.Request().SetRequestURI("/search?q=fiber")
274
275 fullURL := c.FullURL()
276 require.Equal(t, "http://example.com/search?q=fiber", fullURL)
277
278 for range bufferPoolReuseAttempts {
279 buf := bytebufferpool.Get()
280 buf.Reset()
281 buf.WriteString("https://mutated.example/rewritten")
282 bytebufferpool.Put(buf)
283 }
284
285 require.Equal(t, "http://example.com/search?q=fiber", fullURL)
286}
287
288// go test -run Test_Ctx_TypedParsingDefaults
289func Test_Ctx_TypedParsingDefaults(t *testing.T) {

Callers

nothing calls this directly

Calls 8

AcquireCtxMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
FullURLMethod · 0.65
GetMethod · 0.65
ResetMethod · 0.65
WriteStringMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected