From ce81df0c6f0676ed237b407ba7d2afc7c38994b1 Mon Sep 17 00:00:00 2001 From: Nicholas Jackson Date: Mon, 4 Mar 2024 19:35:29 -0800 Subject: [PATCH] fix: merge in v3 client --- client/client_test.go | 8 ++++---- client/request_test.go | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 4fd2e484a63..b1577069516 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -655,7 +655,7 @@ func Test_Client_UserAgent(t *testing.T) { setupApp := func() (*fiber.App, string) { app, addr := startTestServerWithPort(t, func(app *fiber.App) { app.Get("/", func(c fiber.Ctx) error { - return c.Send(c.Request().Header.UserAgent()) + return c.SendString(c.Get(fiber.HeaderUserAgent)) }) }) @@ -777,7 +777,7 @@ func Test_Client_Header(t *testing.T) { func Test_Client_Header_With_Server(t *testing.T) { handler := func(c fiber.Ctx) error { - c.Request().Header.VisitAll(func(key, value []byte) { + c.Context().Request.Header.VisitAll(func(key, value []byte) { if k := string(key); k == "K1" || k == "K2" { _, _ = c.Write(key) //nolint:errcheck // It is fine to ignore the error here _, _ = c.Write(value) //nolint:errcheck // It is fine to ignore the error here @@ -1010,7 +1010,7 @@ func Test_Client_CookieJar_Response(t *testing.T) { func Test_Client_Referer(t *testing.T) { handler := func(c fiber.Ctx) error { - return c.Send(c.Request().Header.Referer()) + return c.SendString(c.Get(fiber.HeaderReferer)) } wrapAgent := func(c *Client) { @@ -1379,7 +1379,7 @@ func Test_Replace(t *testing.T) { app, dial, start := createHelperServer(t) app.Get("/", func(c fiber.Ctx) error { - return c.SendString(string(c.Request().Header.Peek("k1"))) + return c.SendString(c.Get("k1")) }) go start() diff --git a/client/request_test.go b/client/request_test.go index 07e5254e15f..b72c258603f 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -855,7 +855,7 @@ func Test_Request_Patch(t *testing.T) { func Test_Request_Header_With_Server(t *testing.T) { t.Parallel() handler := func(c fiber.Ctx) error { - c.Request().Header.VisitAll(func(key, value []byte) { + c.Context().Request.Header.VisitAll(func(key, value []byte) { if k := string(key); k == "K1" || k == "K2" { _, err := c.Write(key) require.NoError(t, err) @@ -885,7 +885,7 @@ func Test_Request_UserAgent_With_Server(t *testing.T) { t.Parallel() handler := func(c fiber.Ctx) error { - return c.Send(c.Request().Header.UserAgent()) + return c.SendString(c.Get(fiber.HeaderUserAgent)) } t.Run("default", func(t *testing.T) { @@ -923,7 +923,7 @@ func Test_Request_Cookie_With_Server(t *testing.T) { func Test_Request_Referer_With_Server(t *testing.T) { t.Parallel() handler := func(c fiber.Ctx) error { - return c.Send(c.Request().Header.Referer()) + return c.SendString(c.Get(fiber.HeaderReferer)) } wrapAgent := func(req *Request) { @@ -936,7 +936,7 @@ func Test_Request_Referer_With_Server(t *testing.T) { func Test_Request_QueryString_With_Server(t *testing.T) { t.Parallel() handler := func(c fiber.Ctx) error { - return c.Send(c.Request().URI().QueryString()) + return c.Send(c.Context().URI().QueryString()) } wrapAgent := func(req *Request) { @@ -974,8 +974,8 @@ func Test_Request_Body_With_Server(t *testing.T) { t.Parallel() testRequest(t, func(c fiber.Ctx) error { - require.Equal(t, "application/json", string(c.Request().Header.ContentType())) - return c.SendString(string(c.Request().Body())) + require.Equal(t, "application/json", string(c.Get(fiber.HeaderContentType))) + return c.SendString(string(c.Req().BodyRaw())) }, func(agent *Request) { agent.SetJSON(map[string]string{ @@ -990,8 +990,8 @@ func Test_Request_Body_With_Server(t *testing.T) { t.Parallel() testRequest(t, func(c fiber.Ctx) error { - require.Equal(t, "application/xml", string(c.Request().Header.ContentType())) - return c.SendString(string(c.Request().Body())) + require.Equal(t, "application/xml", c.Get(fiber.HeaderContentType)) + return c.SendString(string(c.Req().BodyRaw())) }, func(agent *Request) { type args struct { @@ -1009,7 +1009,7 @@ func Test_Request_Body_With_Server(t *testing.T) { t.Parallel() testRequest(t, func(c fiber.Ctx) error { - require.Equal(t, fiber.MIMEApplicationForm, string(c.Request().Header.ContentType())) + require.Equal(t, fiber.MIMEApplicationForm, string(c.Get(fiber.HeaderContentType))) return c.Send([]byte("foo=" + c.FormValue("foo") + "&bar=" + c.FormValue("bar") + "&fiber=" + c.FormValue("fiber"))) }, func(agent *Request) { @@ -1033,7 +1033,7 @@ func Test_Request_Body_With_Server(t *testing.T) { require.NoError(t, err) require.Equal(t, "bar", mf.Value["foo"][0]) - return c.Send(c.Request().Body()) + return c.Send(c.Req().Body()) }) go start() @@ -1125,7 +1125,7 @@ func Test_Request_Body_With_Server(t *testing.T) { reg := regexp.MustCompile(`multipart/form-data; boundary=[\-\w]{35}`) require.True(t, reg.MatchString(c.Get(fiber.HeaderContentType))) - return c.Send(c.Request().Body()) + return c.Send(c.Req().BodyRaw()) }) go start() @@ -1150,7 +1150,7 @@ func Test_Request_Body_With_Server(t *testing.T) { t.Parallel() testRequest(t, func(c fiber.Ctx) error { - return c.SendString(string(c.Request().Body())) + return c.SendString(string(c.Req().BodyRaw())) }, func(agent *Request) { agent.SetRawBody([]byte("hello")) @@ -1236,7 +1236,7 @@ func Test_Request_MaxRedirects(t *testing.T) { app := fiber.New() app.Get("/", func(c fiber.Ctx) error { - if c.Request().URI().QueryArgs().Has("foo") { + if c.Context().URI().QueryArgs().Has("foo") { return c.Redirect().To("/foo") } return c.Redirect().To("/")