Skip to content

Commit 1fc3c86

Browse files
committed
More robust timeout parser
1 parent f353dbe commit 1fc3c86

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

http/1.4.0/src/app.py

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ def GET(self, url, headers="", username="", password="", verify=True, http_proxy
191191
auth = requests.auth.HTTPBasicAuth(username, password)
192192

193193
if not timeout:
194-
timeout = 5
195-
if timeout:
196-
timeout = int(timeout)
194+
timeout = 25
195+
else:
196+
try:
197+
timeout = int(timeout)
198+
except:
199+
timeout = 25
197200

198201
if to_file == "true":
199202
to_file = True
@@ -229,9 +232,12 @@ def POST(self, url, headers="", body="", username="", password="", verify=True,
229232
auth = requests.auth.HTTPBasicAuth(username, password)
230233

231234
if not timeout:
232-
timeout = 5
233-
if timeout:
234-
timeout = int(timeout)
235+
timeout = 25
236+
else:
237+
try:
238+
timeout = int(timeout)
239+
except:
240+
timeout = 25
235241

236242
if to_file == "true":
237243
to_file = True
@@ -268,9 +274,12 @@ def PUT(self, url, headers="", body="", username="", password="", verify=True, h
268274
auth = requests.auth.HTTPBasicAuth(username, password)
269275

270276
if not timeout:
271-
timeout = 5
272-
if timeout:
273-
timeout = int(timeout)
277+
timeout = 25
278+
else:
279+
try:
280+
timeout = int(timeout)
281+
except:
282+
timeout = 25
274283

275284
if to_file == "true":
276285
to_file = True
@@ -306,9 +315,12 @@ def PATCH(self, url, headers="", body="", username="", password="", verify=True,
306315
auth = requests.auth.HTTPBasicAuth(username, password)
307316

308317
if not timeout:
309-
timeout = 5
310-
if timeout:
311-
timeout = int(timeout)
318+
timeout = 25
319+
else:
320+
try:
321+
timeout = int(timeout)
322+
except:
323+
timeout = 25
312324

313325
if to_file == "true":
314326
to_file = True
@@ -344,9 +356,12 @@ def DELETE(self, url, headers="", body="", username="", password="", verify=True
344356
auth = requests.auth.HTTPBasicAuth(username, password)
345357

346358
if not timeout:
347-
timeout = 5
348-
if timeout:
349-
timeout = int(timeout)
359+
timeout = 25
360+
else:
361+
try:
362+
timeout = int(timeout)
363+
except:
364+
timeout = 25
350365

351366
if to_file == "true":
352367
to_file = True
@@ -382,9 +397,12 @@ def HEAD(self, url, headers="", body="", username="", password="", verify=True,
382397
auth = requests.auth.HTTPBasicAuth(username, password)
383398

384399
if not timeout:
385-
timeout = 5
386-
if timeout:
387-
timeout = int(timeout)
400+
timeout = 25
401+
else:
402+
try:
403+
timeout = int(timeout)
404+
except:
405+
timeout = 25
388406

389407
if to_file == "true":
390408
to_file = True
@@ -420,10 +438,12 @@ def OPTIONS(self, url, headers="", body="", username="", password="", verify=Tru
420438
auth = requests.auth.HTTPBasicAuth(username, password)
421439

422440
if not timeout:
423-
timeout = 5
424-
425-
if timeout:
426-
timeout = int(timeout)
441+
timeout = 25
442+
else:
443+
try:
444+
timeout = int(timeout)
445+
except:
446+
timeout = 25
427447

428448
if to_file == "true":
429449
to_file = True

0 commit comments

Comments
 (0)