Example #1
0
    def test_content_range(self):
        from lxml import etree

        from diazo.wsgi import XSLTMiddleware
        from webob import Request

        def application(environ, start_response):
            status = '200 OK'
            content_length = len(HTML)
            content_range = 'bytes %d-%d/%d' % (0, content_length - 1,
                                                content_length)
            response_headers = [('Content-Type', 'text/html'),
                                ('Content-Range', content_range),
                                ('Content-Length', str(content_length))]
            start_response(status, response_headers)
            return [HTML]

        app = XSLTMiddleware(application, {}, tree=etree.fromstring(XSLT))

        request = Request.blank('/')
        response = request.get_response(app)

        self.assertFalse('Content-Range' in response.headers)
Example #2
0
    def test_content_empty(self):
        from lxml import etree

        from diazo.wsgi import XSLTMiddleware
        from webob import Request

        def application(environ, start_response):
            status = '200 OK'
            response_headers = [('Content-Type', 'text/html'),
                                ('Content-MD5',
                                 'd41d8cd98f00b204e9800998ecf8427e')]
            start_response(status, response_headers)
            return ['']

        app = XSLTMiddleware(application, {},
                             tree=etree.fromstring(XSLT),
                             update_content_length=True)

        request = Request.blank('/')
        response = request.get_response(app)

        self.assertEqual(response.headers['Content-MD5'],
                         'd41d8cd98f00b204e9800998ecf8427e')