From 17f608f0148c2340a811d6eb85bebd2e612f10be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 5 Jul 2013 12:50:10 -0300 Subject: Set global request timeout to REQUEST_TIMEOUT (10 secs) --- src/leap/services/eip/eipbootstrapper.py | 7 +++++-- src/leap/services/eip/providerbootstrapper.py | 13 +++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/leap/services/eip') diff --git a/src/leap/services/eip/eipbootstrapper.py b/src/leap/services/eip/eipbootstrapper.py index b2af0aea..60270b5b 100644 --- a/src/leap/services/eip/eipbootstrapper.py +++ b/src/leap/services/eip/eipbootstrapper.py @@ -31,6 +31,7 @@ from leap.config.providerconfig import ProviderConfig from leap.crypto.srpauth import SRPAuth from leap.services.eip.eipconfig import EIPConfig from leap.util.request_helpers import get_content +from leap.util.constants import REQUEST_TIMEOUT from leap.services.abstractbootstrapper import AbstractBootstrapper logger = logging.getLogger(__name__) @@ -89,7 +90,8 @@ class EIPBootstrapper(AbstractBootstrapper): res = self._session.get(config_uri, verify=self._provider_config .get_ca_cert_path(), - headers=headers) + headers=headers, + timeout=REQUEST_TIMEOUT) res.raise_for_status() # Not modified @@ -139,7 +141,8 @@ class EIPBootstrapper(AbstractBootstrapper): res = self._session.get(cert_uri, verify=self._provider_config .get_ca_cert_path(), - cookies=cookies) + cookies=cookies, + timeout=REQUEST_TIMEOUT) res.raise_for_status() client_cert = res.content diff --git a/src/leap/services/eip/providerbootstrapper.py b/src/leap/services/eip/providerbootstrapper.py index 754d0643..274fd3bd 100644 --- a/src/leap/services/eip/providerbootstrapper.py +++ b/src/leap/services/eip/providerbootstrapper.py @@ -31,6 +31,7 @@ from leap.common.files import check_and_fix_urw_only, get_mtime, mkdir_p from leap.common.check import leap_assert, leap_assert_type from leap.config.providerconfig import ProviderConfig from leap.util.request_helpers import get_content +from leap.util.constants import REQUEST_TIMEOUT from leap.services.abstractbootstrapper import AbstractBootstrapper from leap.provider.supportedapis import SupportedAPIs @@ -103,7 +104,8 @@ class ProviderBootstrapper(AbstractBootstrapper): try: res = self._session.get("https://%s" % (self._domain,), - verify=not self._bypass_checks) + verify=not self._bypass_checks, + timeout=REQUEST_TIMEOUT) res.raise_for_status() except requests.exceptions.SSLError: self._err_msg = self.tr("Provider certificate could " @@ -135,7 +137,8 @@ class ProviderBootstrapper(AbstractBootstrapper): res = self._session.get("https://%s/%s" % (self._domain, "provider.json"), headers=headers, - verify=not self._bypass_checks) + verify=not self._bypass_checks, + timeout=REQUEST_TIMEOUT) res.raise_for_status() # Not modified @@ -220,7 +223,8 @@ class ProviderBootstrapper(AbstractBootstrapper): return res = self._session.get(self._provider_config.get_ca_cert_uri(), - verify=not self._bypass_checks) + verify=not self._bypass_checks, + timeout=REQUEST_TIMEOUT) res.raise_for_status() cert_path = self._provider_config.get_ca_cert_path( @@ -280,7 +284,8 @@ class ProviderBootstrapper(AbstractBootstrapper): self._provider_config.get_api_version()) res = self._session.get(test_uri, verify=self._provider_config - .get_ca_cert_path()) + .get_ca_cert_path(), + timeout=REQUEST_TIMEOUT) res.raise_for_status() def run_provider_setup_checks(self, -- cgit v1.2.3