👷 Add BodyString

pull/1177/head
Kiyon 2021-02-18 17:26:13 +08:00
parent 51986b2e7c
commit e93306ca61
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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(