Skip to content

Commit

Permalink
fix: merge in v3 client
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 committed Mar 5, 2024
1 parent 034ccba commit ce81df0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down
26 changes: 13 additions & 13 deletions client/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)))

Check failure on line 977 in client/request_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
return c.SendString(string(c.Req().BodyRaw()))
},
func(agent *Request) {
agent.SetJSON(map[string]string{
Expand All @@ -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 {
Expand All @@ -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)))

Check failure on line 1012 in client/request_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
return c.Send([]byte("foo=" + c.FormValue("foo") + "&bar=" + c.FormValue("bar") + "&fiber=" + c.FormValue("fiber")))
},
func(agent *Request) {
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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"))
Expand Down Expand Up @@ -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("/")
Expand Down

0 comments on commit ce81df0

Please sign in to comment.