accept iobody the type is string;
This commit is contained in:
parent
a6217886dc
commit
84ae0a710e
4
base.go
4
base.go
|
@ -19,10 +19,12 @@ func buildBodyRequest(wf *Workflow) *http.Request {
|
|||
switch wf.Body.GetIOBody().(type) {
|
||||
case []byte:
|
||||
bodybuf = bytes.NewBuffer(wf.Body.GetIOBody().([]byte))
|
||||
case string:
|
||||
bodybuf = bytes.NewBuffer([]byte(wf.Body.GetIOBody().(string)))
|
||||
case *bytes.Buffer:
|
||||
bodybuf = bytes.NewBuffer(wf.Body.GetIOBody().(*bytes.Buffer).Bytes())
|
||||
default:
|
||||
panic(errors.New("the type is not exist, type is" + reflect.TypeOf(wf.Body.GetIOBody()).String()))
|
||||
panic(errors.New("the type is not exist, type is " + reflect.TypeOf(wf.Body.GetIOBody()).String()))
|
||||
}
|
||||
req, err = http.NewRequest(wf.Method, wf.GetRawURL(), bodybuf)
|
||||
}
|
||||
|
|
28
session.go
28
session.go
|
@ -307,6 +307,13 @@ func (ses *Session) ClearCookies() {
|
|||
ses.client.Jar = ses.cookiejar
|
||||
}
|
||||
|
||||
// Head 请求
|
||||
func (ses *Session) Head(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
wf.Method = "HEAD"
|
||||
return wf
|
||||
}
|
||||
|
||||
// Get 请求
|
||||
func (ses *Session) Get(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
|
@ -335,20 +342,6 @@ func (ses *Session) Patch(url string) *Workflow {
|
|||
return wf
|
||||
}
|
||||
|
||||
// Delete 请求
|
||||
func (ses *Session) Delete(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
wf.Method = "DELETE"
|
||||
return wf
|
||||
}
|
||||
|
||||
// Head 请求
|
||||
func (ses *Session) Head(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
wf.Method = "HEAD"
|
||||
return wf
|
||||
}
|
||||
|
||||
// Options 请求
|
||||
func (ses *Session) Options(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
|
@ -356,6 +349,13 @@ func (ses *Session) Options(url string) *Workflow {
|
|||
return wf
|
||||
}
|
||||
|
||||
// Delete 请求
|
||||
func (ses *Session) Delete(url string) *Workflow {
|
||||
wf := NewWorkflow(ses, url)
|
||||
wf.Method = "DELETE"
|
||||
return wf
|
||||
}
|
||||
|
||||
// CloseIdleConnections closes the idle connections that a session client may make use of
|
||||
// 从levigross/grequests 借鉴
|
||||
func (ses *Session) CloseIdleConnections() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user