6
6
import json
7
7
import time
8
8
import urllib .parse
9
+ import urllib3
9
10
10
11
W = '\033 [0m' # white (normal)
11
12
R = '\033 [31m' # red
15
16
P = '\033 [35m' # purple
16
17
17
18
#Global for access by event hooks
18
- session = requests .Session ()
19
+ session = requests .Session ()
19
20
20
21
def printSummary (s ):
21
22
L = logging .getLogger ("SUMMARY:" )
@@ -69,13 +70,17 @@ def cbLinkFollow(response, *args, **kwargs):
69
70
@click .option ("-T" , "--timeout" , default = 10 , help = "Request timeout in seconds" )
70
71
@click .option ("-a" , "--accept" , default = "*/*" , help = "Accept header value" )
71
72
@click .option ("-j" , "--json" , "json_report" , is_flag = True , help = "Report in JSON" )
73
+ @click .option ("-k" , "--insecure" , default = False , is_flag = True , help = "Don't verify certificates" )
72
74
@click .option ("-b" , "--body" , is_flag = True , help = "Show response body" )
73
75
@click .option ("-L" , "--link-type" , default = None , help = "Follow link header with type" )
74
76
@click .option ("-R" , "--link-rel" , default = 'alternate' , help = "Follow link header with rel" )
75
77
@click .option ("-P" , "--link-profile" , default = None , help = "Follow link header with profile" )
76
- def main (url , timeout , accept , json_report , body , link_type , link_rel , link_profile ):
78
+ def main (url , timeout , accept , json_report , insecure , body , link_type , link_rel , link_profile ):
79
+ if insecure :
80
+ urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
81
+
77
82
logging .basicConfig (
78
- level = logging .INFO ,
83
+ level = logging .INFO ,
79
84
format = "%(asctime)s.%(msecs)03d:%(name)s %(message)s" ,
80
85
datefmt = '%Y-%m-%d %H:%M:%S' )
81
86
accept = htrace .ACCEPT_VALUES .get (accept , accept )
@@ -89,11 +94,11 @@ def main(url, timeout, accept, json_report, body, link_type, link_rel, link_prof
89
94
}
90
95
tstart = time .time ()
91
96
session ._extra = {
92
- 'link_type' :link_type ,
93
- 'link_rel' : link_rel ,
97
+ 'link_type' :link_type ,
98
+ 'link_rel' : link_rel ,
94
99
'link_profile' : link_profile
95
100
}
96
- response = session .get (url , timeout = timeout , headers = headers , hooks = hooks , allow_redirects = True )
101
+ response = session .get (url , timeout = timeout , headers = headers , hooks = hooks , allow_redirects = True , verify = not insecure )
97
102
tend = time .time ()
98
103
summary = htrace .responseSummary (response , tstart , tend )
99
104
if json_report :
0 commit comments