-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.go
55 lines (41 loc) · 1.14 KB
/
make.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package fuzz
import (
"net/http"
"net"
"time"
"strings"
"github.com/neonify/lessgo/pkg/input"
)
func MakeReq(Obj input.Data,HeaderMap map[string]string)(*http.Request,error){
var req *http.Request
var err error
if Obj.Method == "GET"{
req,err = http.NewRequest(Obj.Method,Obj.Url,nil)
}else if Obj.Method == "POST"{
data := input.DataParse(Obj.PostData)
req,err = http.NewRequest(Obj.Method,Obj.Url,strings.NewReader(data.Encode()))
}
for param, value := range(HeaderMap){
req.Header.Set(param,value)
}
return req,err
}
func MakeClient(FR bool,Tmout int)(http.Client){
timeout := time.Duration(time.Duration(Tmout) *time.Second)
tr := &http.Transport{
Dial: (&net.Dialer{
Timeout: timeout,
}).Dial,
TLSHandshakeTimeout: timeout,
MaxIdleConns: 1000,
MaxIdleConnsPerHost: 500,
MaxConnsPerHost: 500,
}
client := http.Client{Timeout:timeout,Transport : tr}
if FR == false{
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
}
return client
}