def _fetch_and_handle_404_from_nicknym(self, uri):
"""
Send a GET request to C{uri} containing C{data}.
:param uri: The URI of the request.
:type uri: str
:return: A deferred that will be fired with GET content as json (dict)
:rtype: Deferred
"""
def check_code(response):
if response.code == NOT_FOUND:
message = ' %s: Key not found. Request: %s' \
% (response.code, uri)
self.log.warn(message)
raise KeyNotFound(message), None, sys.exc_info()[2]
if response.code == SERVICE_UNAVAILABLE:
message = ' %s: Service unavailable (maybe in maintenance).' \
'Request: %s' % (response.code, uri)
self.log.warn(message)
raise KeyNotFound(message), None, sys.exc_info()[2]
if response.code == BAD_GATEWAY:
message = ' %s: Bad gateway. Request: %s. Response: %s' \
% (response.code, uri, response)
self.log.warn(message)
raise KeyNotFound(message), None, sys.exc_info()[2]
return response
d = self._async_client_pinned.request(str(uri), 'GET',
callback=check_code)
d.addCallback(client.readBody)
return d
评论列表
文章目录