def test_chunked_length(self): req = HttpRequest( 'get', 'http://python.org/', headers={'Content-Length': '1000'}, chunked=1024) req.send(self.transport) self.assertEqual(req.headers['Transfer-Encoding'], 'chunked') self.assertNotIn('Content-Length', req.headers)
def test_chunked_explicit_size(self, m_tulip): req = HttpRequest( 'get', 'http://python.org/', chunked=1024) req.send(self.transport) self.assertEqual('chunked', req.headers['Transfer-encoding']) m_tulip.http.Request.return_value\ .add_chunking_filter.assert_called_with(1024)
def test_content_encoding(self, m_tulip): req = HttpRequest('get', 'http://python.org/', compress='deflate') req.send(self.transport) self.assertEqual(req.headers['Transfer-encoding'], 'chunked') self.assertEqual(req.headers['Content-encoding'], 'deflate') m_tulip.http.Request.return_value\ .add_compression_filter.assert_called_with('deflate')
def test_post_data(self): for meth in HttpRequest.POST_METHODS: req = HttpRequest(meth, 'http://python.org/', data={'life': '42'}) req.send(self.transport) self.assertEqual('/', req.path) self.assertEqual(b'life=42', req.body[0]) self.assertEqual('application/x-www-form-urlencoded', req.headers['content-type'])
def test_no_content_length(self): req = HttpRequest('get', 'http://python.org') req.send(self.transport) self.assertEqual('0', req.headers.get('Content-Length')) req = HttpRequest('head', 'http://python.org') req.send(self.transport) self.assertEqual('0', req.headers.get('Content-Length'))
def test_chunked(self): req = HttpRequest( 'get', 'http://python.org/', headers={'Transfer-encoding': 'gzip'}) req.send(self.transport) self.assertEqual('gzip', req.headers['Transfer-encoding']) req = HttpRequest( 'get', 'http://python.org/', headers={'Transfer-encoding': 'chunked'}) req.send(self.transport) self.assertEqual('chunked', req.headers['Transfer-encoding'])