| skipped 2 lines |
3 | 3 | | import ( |
4 | 4 | | "crypto/tls" |
5 | 5 | | "fmt" |
6 | | - | "io/ioutil" |
| 6 | + | "io" |
7 | 7 | | "net" |
8 | 8 | | "net/http" |
9 | 9 | | "time" |
| 10 | + | ) |
| 11 | + | |
| 12 | + | const ( |
| 13 | + | TLSHandshakeTimeout = 10 |
| 14 | + | KeepAlive = 30 |
10 | 15 | | ) |
11 | 16 | | |
12 | 17 | | func checkCSP(url string, client *http.Client) ([]string, error) { |
| skipped 8 lines |
21 | 26 | | return result, nil |
22 | 27 | | } |
23 | 28 | | |
24 | | - | body, err := ioutil.ReadAll(resp.Body) |
25 | | - | |
26 | | - | if resp != nil { |
27 | | - | defer resp.Body.Close() |
28 | | - | } |
| 29 | + | body, _ := io.ReadAll(resp.Body) |
| 30 | + | defer resp.Body.Close() |
29 | 31 | | |
30 | 32 | | headerCSP := resp.Header.Get("Content-Security-Policy") |
31 | 33 | | |
| skipped 12 lines |
44 | 46 | | Dial: (&net.Dialer{ |
45 | 47 | | // Modify the time to wait for a connection to establish |
46 | 48 | | Timeout: time.Duration(timeout) * time.Second, |
47 | | - | KeepAlive: 30 * time.Second, |
| 49 | + | KeepAlive: KeepAlive * time.Second, |
48 | 50 | | }).Dial, |
49 | | - | TLSHandshakeTimeout: 10 * time.Second, |
| 51 | + | TLSHandshakeTimeout: TLSHandshakeTimeout * time.Second, |
50 | 52 | | } |
51 | 53 | | |
52 | 54 | | client := http.Client{ |
| skipped 7 lines |