Skip to content

Commit

Permalink
(Closed #35) Add http client timetout / netTransport timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Apr 24, 2020
1 parent 0d8b471 commit 2f86245
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/scanning/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"io/ioutil"
"net"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -503,7 +504,16 @@ func SendReq(url, payload string, options_string map[string]string) (string, *ht
req.Header.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0")
}

var netTransport = &http.Transport{
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
}).Dial,
TLSHandshakeTimeout: 5 * time.Second,
}

client := &http.Client{
Timeout: time.Second * 10,
Transport: netTransport,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return errors.New("something bad happened") // or maybe the error from the request
},
Expand Down

0 comments on commit 2f86245

Please sign in to comment.