mirror of https://github.com/gofiber/fiber.git
👷 Add BodyString
parent
51986b2e7c
commit
e93306ca61
|
@ -259,6 +259,13 @@ func (a *Agent) QueryString(queryString string) *Agent {
|
|||
return a
|
||||
}
|
||||
|
||||
// BodyString sets request body.
|
||||
func (a *Agent) BodyString(bodyString string) *Agent {
|
||||
a.req.SetBodyString(bodyString)
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// BodyStream sets request body stream and, optionally body size.
|
||||
//
|
||||
// If bodySize is >= 0, then the bodyStream must provide exactly bodySize bytes
|
||||
|
|
|
@ -252,6 +252,18 @@ func Test_Client_Agent_QueryString(t *testing.T) {
|
|||
testAgent(t, handler, wrapAgent, "foo=bar&bar=baz")
|
||||
}
|
||||
|
||||
func Test_Client_Agent_BodyString(t *testing.T) {
|
||||
handler := func(c *Ctx) error {
|
||||
return c.Send(c.Request().Body())
|
||||
}
|
||||
|
||||
wrapAgent := func(a *Agent) {
|
||||
a.BodyString("foo=bar&bar=baz")
|
||||
}
|
||||
|
||||
testAgent(t, handler, wrapAgent, "foo=bar&bar=baz")
|
||||
}
|
||||
|
||||
func Test_Client_Agent_Cookie(t *testing.T) {
|
||||
handler := func(c *Ctx) error {
|
||||
return c.SendString(
|
||||
|
|
Loading…
Reference in New Issue