本文整理汇总了Python中eventlet.green.httplib.HTTPSConnection.getresponse方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPSConnection.getresponse方法的具体用法?Python HTTPSConnection.getresponse怎么用?Python HTTPSConnection.getresponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet.green.httplib.HTTPSConnection
的用法示例。
在下文中一共展示了HTTPSConnection.getresponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_to_peer
# 需要导入模块: from eventlet.green.httplib import HTTPSConnection [as 别名]
# 或者: from eventlet.green.httplib.HTTPSConnection import getresponse [as 别名]
def send_to_peer(self, peer, sync_to_peer, key):
peer = peer.lower()
ssl = False
if peer.startswith('https://'):
ssl = True
peer = peer[8:]
if peer.startswith('http://'):
peer = peer[7:]
try:
with Timeout(self.conn_timeout):
if ssl:
#print 'HTTPS %s ' % peer
conn = HTTPSConnection(peer)
else:
#print 'HTTP %s ' % peer
conn = HTTPConnection(peer)
conn.putrequest(self.req.method, self.req.path_qs)
conn.putheader('X-Orig-Cluster', self.my_cluster)
conn.putheader('X-Account-Meta-Orig-Cluster', self.my_cluster)
conn.putheader('X-Container-Meta-Orig-Cluster', self.my_cluster)
if key:
sync_to = sync_to_peer + self.env['PATH_INFO']
conn.putheader('X-Container-Sync-To', sync_to)
for header, value in self.req.headers.iteritems():
if header != 'X-Container-Sync-To':
conn.putheader(header, value)
conn.endheaders(message_body=None)
with Timeout(self.req_timeout):
resp = conn.getresponse()
status = resp.status
return (status, resp.getheaders(), resp.read())
except (Exception, Timeout) as e:
# Print error log
print >> sys.stderr, peer + ': Exception, Timeout error: %s' % e
print '<<<<<<<< HTTP_SERVICE_UNAVAILABLE'