def __snd_request(self, method, uri, headers={}, body='', eh=1):
try:
h = HTTP()
h.connect(self.host, self.port)
h.putrequest(method, uri)
for n, v in headers.items():
h.putheader(n, v)
if eh:
h.endheaders()
if body:
h.send(body)
ver, code, msg, hdrs = h.getreply()
data = h.getfile().read()
h.close()
except Exception:
raise NotAvailable(sys.exc_value)
return http_response(ver, code, msg, hdrs, data)
# HTTP methods
评论列表
文章目录