From 0449e2679f2b251871cf60151c689813aa21bfc9 Mon Sep 17 00:00:00 2001 From: Guillaume Nourry-Marquis Date: Mon, 9 Feb 2015 13:28:18 -0500 Subject: [PATCH] Bypass proxy caching Add a HTTP Header that prevents HTTP proxy from caching the download file. Tested with Bluecoat ProxySG in between. --- speedtest_cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/speedtest_cli.py b/speedtest_cli.py index 105c390..93eb84b 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -178,7 +178,10 @@ class FileGetter(threading.Thread): self.result = [0] try: if (timeit.default_timer() - self.starttime) <= 10: - f = urlopen(self.url) + #XLASH 2015-02-09 This is to prevent Proxy Caching in the way + req = Request(self.url) + req.add_header('Cache-Control' , 'no-cache') + f = urlopen(req) while 1 and not shutdown_event.isSet(): self.result.append(len(f.read(10240))) if self.result[-1] == 0: