__init__.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:download-manager 作者: thispc 项目源码 文件源码
def simple_response(self, status, msg=""):
        """Write a simple response back to the client."""
        status = str(status)
        buf = ["%s %s\r\n" % (self.environ['ACTUAL_SERVER_PROTOCOL'], status),
               "Content-Length: %s\r\n" % len(msg),
               "Content-Type: text/plain\r\n"]

        if status[:3] == "413" and self.response_protocol == 'HTTP/1.1':
            # Request Entity Too Large
            self.close_connection = True
            buf.append("Connection: close\r\n")

        buf.append("\r\n")
        if msg:
            buf.append(msg)

        try:
            self.wfile.sendall("".join(buf))
        except socket.error, x:
            if x.args[0] not in socket_errors_to_ignore:
                raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号