Loading sbws/core/scanner.py +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ def timed_recv_from_server(session, dest, byte_range): # - What other exceptions can this throw? # - Do we have to read the content, or did requests already do so? try: requests_utils.get( session, dest.url, headers=headers, verify=dest.verify) # headers are merged with the session ones, not overwritten. session.get(dest.url, headers=headers, verify=dest.verify) except requests.exceptions.ConnectionError as e: return False, e except requests.exceptions.ReadTimeout as e: Loading sbws/lib/destination.py +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def connect_to_destination_over_circuit(dest, circ_id, session, cont, max_dl): try: # TODO: # - What other exceptions can this throw? head = requests_utils.head(session, dest.url, verify=dest.verify) head = session.head(dest.url, verify=dest.verify) except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as e: return False, 'Could not connect to {} over circ {} {}: {}'.format( Loading sbws/util/requests.py +2 −10 Original line number Diff line number Diff line Loading @@ -5,17 +5,9 @@ import sbws.util.stem as stem_utils def make_session(controller, timeout): s = requests.Session() socks_info = stem_utils.get_socks_info(controller) s.sbws_proxies = { s.proxies = { 'http': 'socks5h://{}:{}'.format(*socks_info), 'https': 'socks5h://{}:{}'.format(*socks_info), } s.sbws_timeout = timeout s.timeout = timeout return s def get(s, url, **kw): return s.get(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw) def head(s, url, **kw): return s.head(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw) Loading
sbws/core/scanner.py +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ def timed_recv_from_server(session, dest, byte_range): # - What other exceptions can this throw? # - Do we have to read the content, or did requests already do so? try: requests_utils.get( session, dest.url, headers=headers, verify=dest.verify) # headers are merged with the session ones, not overwritten. session.get(dest.url, headers=headers, verify=dest.verify) except requests.exceptions.ConnectionError as e: return False, e except requests.exceptions.ReadTimeout as e: Loading
sbws/lib/destination.py +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ def connect_to_destination_over_circuit(dest, circ_id, session, cont, max_dl): try: # TODO: # - What other exceptions can this throw? head = requests_utils.head(session, dest.url, verify=dest.verify) head = session.head(dest.url, verify=dest.verify) except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as e: return False, 'Could not connect to {} over circ {} {}: {}'.format( Loading
sbws/util/requests.py +2 −10 Original line number Diff line number Diff line Loading @@ -5,17 +5,9 @@ import sbws.util.stem as stem_utils def make_session(controller, timeout): s = requests.Session() socks_info = stem_utils.get_socks_info(controller) s.sbws_proxies = { s.proxies = { 'http': 'socks5h://{}:{}'.format(*socks_info), 'https': 'socks5h://{}:{}'.format(*socks_info), } s.sbws_timeout = timeout s.timeout = timeout return s def get(s, url, **kw): return s.get(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw) def head(s, url, **kw): return s.head(url, timeout=s.sbws_timeout, proxies=s.sbws_proxies, **kw)