Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce81df0

Browse files
committedMar 5, 2024·
fix: merge in v3 client
1 parent 034ccba commit ce81df0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed
 

‎client/client_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ func Test_Client_UserAgent(t *testing.T) {
655655
setupApp := func() (*fiber.App, string) {
656656
app, addr := startTestServerWithPort(t, func(app *fiber.App) {
657657
app.Get("/", func(c fiber.Ctx) error {
658-
return c.Send(c.Request().Header.UserAgent())
658+
return c.SendString(c.Get(fiber.HeaderUserAgent))
659659
})
660660
})
661661

@@ -777,7 +777,7 @@ func Test_Client_Header(t *testing.T) {
777777

778778
func Test_Client_Header_With_Server(t *testing.T) {
779779
handler := func(c fiber.Ctx) error {
780-
c.Request().Header.VisitAll(func(key, value []byte) {
780+
c.Context().Request.Header.VisitAll(func(key, value []byte) {
781781
if k := string(key); k == "K1" || k == "K2" {
782782
_, _ = c.Write(key) //nolint:errcheck // It is fine to ignore the error here
783783
_, _ = 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) {
10101010

10111011
func Test_Client_Referer(t *testing.T) {
10121012
handler := func(c fiber.Ctx) error {
1013-
return c.Send(c.Request().Header.Referer())
1013+
return c.SendString(c.Get(fiber.HeaderReferer))
10141014
}
10151015

10161016
wrapAgent := func(c *Client) {
@@ -1379,7 +1379,7 @@ func Test_Replace(t *testing.T) {
13791379
app, dial, start := createHelperServer(t)
13801380

13811381
app.Get("/", func(c fiber.Ctx) error {
1382-
return c.SendString(string(c.Request().Header.Peek("k1")))
1382+
return c.SendString(c.Get("k1"))
13831383
})
13841384

13851385
go start()

‎client/request_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ func Test_Request_Patch(t *testing.T) {
855855
func Test_Request_Header_With_Server(t *testing.T) {
856856
t.Parallel()
857857
handler := func(c fiber.Ctx) error {
858-
c.Request().Header.VisitAll(func(key, value []byte) {
858+
c.Context().Request.Header.VisitAll(func(key, value []byte) {
859859
if k := string(key); k == "K1" || k == "K2" {
860860
_, err := c.Write(key)
861861
require.NoError(t, err)
@@ -885,7 +885,7 @@ func Test_Request_UserAgent_With_Server(t *testing.T) {
885885
t.Parallel()
886886

887887
handler := func(c fiber.Ctx) error {
888-
return c.Send(c.Request().Header.UserAgent())
888+
return c.SendString(c.Get(fiber.HeaderUserAgent))
889889
}
890890

891891
t.Run("default", func(t *testing.T) {
@@ -923,7 +923,7 @@ func Test_Request_Cookie_With_Server(t *testing.T) {
923923
func Test_Request_Referer_With_Server(t *testing.T) {
924924
t.Parallel()
925925
handler := func(c fiber.Ctx) error {
926-
return c.Send(c.Request().Header.Referer())
926+
return c.SendString(c.Get(fiber.HeaderReferer))
927927
}
928928

929929
wrapAgent := func(req *Request) {
@@ -936,7 +936,7 @@ func Test_Request_Referer_With_Server(t *testing.T) {
936936
func Test_Request_QueryString_With_Server(t *testing.T) {
937937
t.Parallel()
938938
handler := func(c fiber.Ctx) error {
939-
return c.Send(c.Request().URI().QueryString())
939+
return c.Send(c.Context().URI().QueryString())
940940
}
941941

942942
wrapAgent := func(req *Request) {
@@ -974,8 +974,8 @@ func Test_Request_Body_With_Server(t *testing.T) {
974974
t.Parallel()
975975
testRequest(t,
976976
func(c fiber.Ctx) error {
977-
require.Equal(t, "application/json", string(c.Request().Header.ContentType()))
978-
return c.SendString(string(c.Request().Body()))
977+
require.Equal(t, "application/json", string(c.Get(fiber.HeaderContentType)))
978+
return c.SendString(string(c.Req().BodyRaw()))
979979
},
980980
func(agent *Request) {
981981
agent.SetJSON(map[string]string{
@@ -990,8 +990,8 @@ func Test_Request_Body_With_Server(t *testing.T) {
990990
t.Parallel()
991991
testRequest(t,
992992
func(c fiber.Ctx) error {
993-
require.Equal(t, "application/xml", string(c.Request().Header.ContentType()))
994-
return c.SendString(string(c.Request().Body()))
993+
require.Equal(t, "application/xml", c.Get(fiber.HeaderContentType))
994+
return c.SendString(string(c.Req().BodyRaw()))
995995
},
996996
func(agent *Request) {
997997
type args struct {
@@ -1009,7 +1009,7 @@ func Test_Request_Body_With_Server(t *testing.T) {
10091009
t.Parallel()
10101010
testRequest(t,
10111011
func(c fiber.Ctx) error {
1012-
require.Equal(t, fiber.MIMEApplicationForm, string(c.Request().Header.ContentType()))
1012+
require.Equal(t, fiber.MIMEApplicationForm, string(c.Get(fiber.HeaderContentType)))
10131013
return c.Send([]byte("foo=" + c.FormValue("foo") + "&bar=" + c.FormValue("bar") + "&fiber=" + c.FormValue("fiber")))
10141014
},
10151015
func(agent *Request) {
@@ -1033,7 +1033,7 @@ func Test_Request_Body_With_Server(t *testing.T) {
10331033
require.NoError(t, err)
10341034
require.Equal(t, "bar", mf.Value["foo"][0])
10351035

1036-
return c.Send(c.Request().Body())
1036+
return c.Send(c.Req().Body())
10371037
})
10381038

10391039
go start()
@@ -1125,7 +1125,7 @@ func Test_Request_Body_With_Server(t *testing.T) {
11251125
reg := regexp.MustCompile(`multipart/form-data; boundary=[\-\w]{35}`)
11261126
require.True(t, reg.MatchString(c.Get(fiber.HeaderContentType)))
11271127

1128-
return c.Send(c.Request().Body())
1128+
return c.Send(c.Req().BodyRaw())
11291129
})
11301130

11311131
go start()
@@ -1150,7 +1150,7 @@ func Test_Request_Body_With_Server(t *testing.T) {
11501150
t.Parallel()
11511151
testRequest(t,
11521152
func(c fiber.Ctx) error {
1153-
return c.SendString(string(c.Request().Body()))
1153+
return c.SendString(string(c.Req().BodyRaw()))
11541154
},
11551155
func(agent *Request) {
11561156
agent.SetRawBody([]byte("hello"))
@@ -1236,7 +1236,7 @@ func Test_Request_MaxRedirects(t *testing.T) {
12361236
app := fiber.New()
12371237

12381238
app.Get("/", func(c fiber.Ctx) error {
1239-
if c.Request().URI().QueryArgs().Has("foo") {
1239+
if c.Context().URI().QueryArgs().Has("foo") {
12401240
return c.Redirect().To("/foo")
12411241
}
12421242
return c.Redirect().To("/")

0 commit comments

Comments
 (0)
Please sign in to comment.