forked from asmcos/requests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests_debug.go
41 lines (38 loc) · 924 Bytes
/
requests_debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package requests
import (
"fmt"
"net/http/httputil"
)
func (session *Session) RequestDebug() string {
if !session.isdebug {
return ""
}
fmt.Println("-----------Go RequestDebug !------------")
curl := BuildCurlRequest(session.httpreq, session.Client.Jar)
fmt.Println(curl)
message, err := httputil.DumpRequestOut(session.httpreq, false)
if err != nil {
return ""
}
fmt.Println(string(message))
fmt.Println("-----Go RequestDebug(end)!------------")
return curl
}
func (session *Session) SetDebug() *Session {
session.isdebug = true
return session
}
func (session *Session) SetDebugBody() *Session {
session.isdebug = true
session.isdebugBody = true
return session
}
func (session *Session) SetDoNotCloseBody(flag bool) *Session {
session.doNotCloseBody = flag
return session
}
func (session *Session) DisableDebug() *Session {
session.isdebug = false
session.isdebugBody = false
return session
}