66 "time"
77)
88
9- func InIt (mode int , timeout int , proxy string , retry int , h1 bool ) (client * req.Client ) {
9+ func InIt (mode int , timeout int , proxy string , retry int , h1 bool , redirect bool ) (client * req.Client ) {
1010 log .Debugf ("init httpclient" )
1111 client = req .NewClient ()
1212 if mode != 0 {
@@ -23,9 +23,13 @@ func InIt(mode int, timeout int, proxy string, retry int, h1 bool) (client *req.
2323 // 设置超时时间
2424 client .SetTimeout (time .Duration (timeout ) * time .Second )
2525 client .SetCommonRetryCount (retry )
26+
2627 client .EnableInsecureSkipVerify ()
27- // 重定向设置
28- client .SetRedirectPolicy (req .NoRedirectPolicy ())
28+ // 重定向设置, 如果不设置, 默认为true 即重定向
29+ if ! redirect {
30+ log .Debug ("redirect is true" )
31+ client .SetRedirectPolicy (req .NoRedirectPolicy ())
32+ }
2933 // 设置代理
3034 f := IsProxyUrl (proxy )
3135 if f {
@@ -51,8 +55,9 @@ func Send(hashmap map[string]interface{}) (resp *req.Response) {
5155 headers := hashmap ["headers" ].(map [string ]string )
5256 body := hashmap ["body" ]
5357 h1 := hashmap ["h1" ].(bool )
58+ redirect := hashmap ["redirect" ].(bool )
5459
55- client := InIt (mode , timeout , proxy , retry , h1 )
60+ client := InIt (mode , timeout , proxy , retry , h1 , redirect )
5661
5762 reqt := client .R ().EnableDump ()
5863 reqs := SetRequest (reqt , headers , body .(string ))
0 commit comments