mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Add in detection of refused connections to the API.
This commit is contained in:
@@ -2,6 +2,7 @@ import httplib
|
|||||||
import urllib
|
import urllib
|
||||||
import xml
|
import xml
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import socket
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@@ -47,7 +48,10 @@ class CachedDocumentManager(models.Manager):
|
|||||||
method = 'POST'
|
method = 'POST'
|
||||||
|
|
||||||
headers = {"Content-type": "application/x-www-form-urlencoded"}
|
headers = {"Content-type": "application/x-www-form-urlencoded"}
|
||||||
conn = httplib.HTTPConnection(API_URL)
|
try:
|
||||||
|
conn = httplib.HTTPConnection(API_URL)
|
||||||
|
except socket.error:
|
||||||
|
return None
|
||||||
conn.request(method, url_path, paramstr, headers)
|
conn.request(method, url_path, paramstr, headers)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user