File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,6 +260,31 @@ func Test_Ctx_HeaderHelpers(t *testing.T) {
260260 require .False (t , c .HasHeader ("X-Trace-Id" ))
261261}
262262
263+ // go test -run Test_Ctx_FullURL_DoesNotAliasPooledBuffer
264+ func 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+
263288// go test -run Test_Ctx_TypedParsingDefaults
264289func Test_Ctx_TypedParsingDefaults (t * testing.T ) {
265290 t .Parallel ()
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ func (c *DefaultCtx) FullURL() string {
215215 buf .WriteString (c .Host ())
216216 buf .WriteString (c .OriginalURL ())
217217
218- return c . app . toString ( buf .Bytes () )
218+ return buf .String ( )
219219}
220220
221221// UserAgent returns the User-Agent request header.
You can’t perform that action at this time.
0 commit comments