diff --git a/pkg/route/engine.go b/pkg/route/engine.go index 5f2ed4bf2..c5a023bee 100644 --- a/pkg/route/engine.go +++ b/pkg/route/engine.go @@ -755,7 +755,7 @@ func (engine *Engine) ServeHTTP(c context.Context, ctx *app.RequestContext) { defer engine.recv(ctx) } - rPath := string(ctx.Request.URI().Path()) + rPath := bytesconv.B2s(ctx.Request.URI().Path()) // align with https://datatracker.ietf.org/doc/html/rfc2616#section-5.2 if len(ctx.Request.Host()) == 0 && ctx.Request.Header.IsHTTP11() && bytesconv.B2s(ctx.Request.Method()) != consts.MethodConnect { @@ -767,7 +767,7 @@ func (engine *Engine) ServeHTTP(c context.Context, ctx *app.RequestContext) { httpMethod := bytesconv.B2s(ctx.Request.Header.Method()) unescape := false if engine.options.UseRawPath { - rPath = string(ctx.Request.URI().PathOriginal()) + rPath = bytesconv.B2s(ctx.Request.URI().PathOriginal()) unescape = engine.options.UnescapePathValues } diff --git a/pkg/route/routes_timing_test.go b/pkg/route/routes_timing_test.go index d0f18a466..04074e964 100644 --- a/pkg/route/routes_timing_test.go +++ b/pkg/route/routes_timing_test.go @@ -627,7 +627,7 @@ func BenchmarkRouteStatic(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { r.ServeHTTP(context.Background(), ctx) - // ctx.index = -1 + ctx.SetIndex(-1) } } @@ -640,7 +640,7 @@ func BenchmarkRouteParam(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { r.ServeHTTP(context.Background(), ctx) - // ctx.index = -1 + ctx.SetIndex(-1) } } @@ -653,6 +653,6 @@ func BenchmarkRouteAny(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { r.ServeHTTP(context.Background(), ctx) - // ctx.index = -1 + ctx.SetIndex(-1) } }