I use httplib to access the api via https and you need to build exception handling in case the api does not work.
Here's an example connection:
connection = httplib.HTTPSConnection('non-existent-api.com', timeout=1)
connection.request('POST', '/request.api', xml, headers={'Content-Type': 'text/xml'})
response = connection.getresponse()
This should wait time, so I was expecting the exception to be raised, but response.read()just returning an empty string.
How to find out if there was a timeout? Better yet, what's the best way to gracefully deal with the problem of third-party attack?
source
share