From 9b39cf97ec104a7dd93694c50eb14ba1199aabef Mon Sep 17 00:00:00 2001 From: "Guilherme M. Prestes da Silva" Date: Fri, 28 Apr 2023 10:11:09 -0300 Subject: [PATCH] providers inform wrong url server pathing that --- speedtest.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/speedtest.py b/speedtest.py index 3413c5d..9fbb68d 100755 --- a/speedtest.py +++ b/speedtest.py @@ -524,7 +524,7 @@ def _build_connection(connection, source_address, timeout, context=None): """ def inner(host, **kwargs): kwargs.update({ - 'source_address': source_address.rstrip(), + 'source_address': source_address, 'timeout': timeout }) if context: @@ -717,8 +717,6 @@ def build_request(url, data=None, headers=None, bump='0', secure=False): int(timeit.time.time() * 1000), bump) - final_url = final_url.rstrip() - headers.update({ 'Cache-Control': 'no-cache', }) @@ -1353,6 +1351,13 @@ class Speedtest(object): attrib['d'] = d + try: + url_final = attrib.get('url').replace(" ", "%20").rstrip() + attrib['url'] = url_final + except Exception: + continue + + try: self.servers[d].append(attrib) except KeyError: @@ -1462,7 +1467,7 @@ class Speedtest(object): results = {} for server in servers: cum = [] - url = os.path.dirname(server['url'].rstrip()) + url = os.path.dirname(server['url']) stamp = int(timeit.time.time() * 1000) latency_url = '%s/latency.txt?x=%s' % (url, stamp) for i in range(0, 3):