From 61810ad6f4173472077e4a3eb26b940afff3cfae Mon Sep 17 00:00:00 2001 From: "Guilherme M. Prestes da Silva" Date: Fri, 28 Apr 2023 09:27:23 -0300 Subject: [PATCH 1/4] rstrip() in url to prevent errors =( --- speedtest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/speedtest.py b/speedtest.py index 186b529..ae61f79 100755 --- a/speedtest.py +++ b/speedtest.py @@ -698,6 +698,9 @@ def build_request(url, data=None, headers=None, bump='0', secure=False): if not headers: headers = {} + # DID YOU HEARD ABOUT 'THE' LORD? + url = url.rstrip() + if url[0] == ':': scheme = ('http', 'https')[bool(secure)] schemed_url = '%s%s' % (scheme, url) From af90f32587b62bdffd7e2b1f88e0e9ec2291bc29 Mon Sep 17 00:00:00 2001 From: "Guilherme M. Prestes da Silva" Date: Fri, 28 Apr 2023 09:28:42 -0300 Subject: [PATCH 2/4] Change contact info --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f3d21ad..25bb3a5 100644 --- a/setup.py +++ b/setup.py @@ -62,9 +62,9 @@ setup( 'speedtest.net'), long_description=long_description, keywords='speedtest speedtest.net', - author='Matt Martz', - author_email='matt@sivel.net', - url='https://github.com/sivel/speedtest-cli', + author='Gmprestes', + author_email='gmprestes@gmail.com', + url='https://github.com/gmprestes/speedtest-cli', license='Apache License, Version 2.0', py_modules=['speedtest'], entry_points={ From 214d996cede3b34a188019880df1c96c28e2f92d Mon Sep 17 00:00:00 2001 From: "Guilherme M. Prestes da Silva" Date: Fri, 28 Apr 2023 09:40:23 -0300 Subject: [PATCH 3/4] some rstrip ajustments --- speedtest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/speedtest.py b/speedtest.py index ae61f79..3413c5d 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, + 'source_address': source_address.rstrip(), 'timeout': timeout }) if context: @@ -699,7 +699,7 @@ def build_request(url, data=None, headers=None, bump='0', secure=False): headers = {} # DID YOU HEARD ABOUT 'THE' LORD? - url = url.rstrip() + if url[0] == ':': scheme = ('http', 'https')[bool(secure)] @@ -717,6 +717,8 @@ 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', }) @@ -1460,7 +1462,7 @@ class Speedtest(object): results = {} for server in servers: cum = [] - url = os.path.dirname(server['url']) + url = os.path.dirname(server['url'].rstrip()) stamp = int(timeit.time.time() * 1000) latency_url = '%s/latency.txt?x=%s' % (url, stamp) for i in range(0, 3): 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 4/4] 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):