Handle HTTP error

This commit is contained in:
Roland Hedberg
2013-01-18 15:09:56 +01:00
parent 13f327c0bc
commit 0e49a3c6d2
2 changed files with 7 additions and 4 deletions

View File

@@ -18,6 +18,7 @@
"""Contains classes and functions that a SAML2.0 Service Provider (SP) may use
to conclude its tasks.
"""
from saml2.httpbase import HTTPError
from saml2.s_utils import sid
from saml2.samlp import logout_response_from_string
import saml2
@@ -244,7 +245,7 @@ class Saml2Client(Base):
response = self.send_using_soap(query, destination)
if response:
if response.status_code == 200:
if not response_args:
response_args = {"binding": BINDING_SOAP}
else:
@@ -252,9 +253,11 @@ class Saml2Client(Base):
logger.info("Verifying response")
if response_args:
response = _response_func(response, **response_args)
response = _response_func(response.text, **response_args)
else:
response = _response_func(response)
response = _response_func(response.text)
else:
raise HTTPError("%d:%s" % (response.status_code, response.error))
if response:
#not_done.remove(entity_id)

View File

@@ -294,7 +294,7 @@ class HTTPBase(object):
if response:
if response.status_code == 200:
logger.info("SOAP response: %s" % response.text)
return response.text
return response
else:
raise HTTPError("%d:%s" % (response.status_code, response.error))
else: