def close(self):
"""
Close the output stream. Called after the last data is sent.
"""
if self._closed:
return
try:
self.conn.send(b'0\r\n\r\n')
resp = self.conn.getresponse()
if resp.status >= 300 and resp.status < 400:
raise Exception('Redirects are not supported for streaming '
'requests at this time. %d to Location: %s' % (
resp.status, resp.getheader('Location')))
if resp.status >= 400:
raise Exception(
'HTTP stream output to %s failed with status %d. Response '
'was: %s' % (
self.output_spec['url'], resp.status, resp.read()))
finally:
self.conn.close()
评论列表
文章目录