HTTPResponse.py 文件源码

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

项目:w4py 作者: Cito 项目源码 文件源码
def writeHeaders(self):
        """Write headers to the response stream. Used internally."""
        if self._committed:
            print "response.writeHeaders called when already committed"
            return
        # make sure the status header comes first
        if 'Status' in self._headers:
            # store and temporarily delete status
            status = self._headers['Status']
            del self._headers['Status']
        else:
            # invent meaningful status
            status = '302 Found' if 'Location' in self._headers else '200 OK'
        head = ['Status: %s' % status]
        head.extend(map(lambda h: '%s: %s' % h, self._headers.items()))
        self._headers['Status'] = status  # restore status
        head.extend(map(lambda c: 'Set-Cookie: %s' % c.headerValue(),
            self._cookies.values()))
        head.extend(['']*2)  # this adds one empty line
        head = '\r\n'.join(head)
        self._strmOut.prepend(head)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号