test_httplib.py 文件源码

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

项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码
def test_malformed_truncation(self):
        # Other malformed header lines, especially without colons, used to
        # cause the rest of the header section to be truncated
        resp = (
            b'HTTP/1.1 200 OK\r\n'
            b'Public-Key-Pins: \n'
            b'pin-sha256="xxx=";\n'
            b'report-uri="https://..."\r\n'
            b'Transfer-Encoding: chunked\r\n'
            b'\r\n'
            b'4\r\nbody\r\n0\r\n\r\n'
        )
        resp = httplib.HTTPResponse(FakeSocket(resp))
        resp.begin()
        self.assertIsNotNone(resp.getheader('Public-Key-Pins'))
        self.assertEqual(resp.getheader('Transfer-Encoding'), 'chunked')
        self.assertEqual(resp.read(), b'body')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号