예제 #1
0
    def test_sendfile_debug(self):
        with self.settings(DEBUG=True):
            resp = sendfile('/foo')
            self.assertEqual(resp['X-Accel-Redirect'], '/foo')
            self.assertEqual(resp.content, '/foo')

        with self.settings(DEBUG=False):
            resp = sendfile('/foo')
            self.assertEqual(resp['X-Accel-Redirect'], '/foo')
            self.assertEqual(resp.content, '')
예제 #2
0
    def get(self, request, conversation):
        direction = request.GET.get('direction', 'inbound')
        if direction not in ['inbound', 'outbound']:
            raise Http404()

        url = '/message_store_exporter/%s/%s.json' % (conversation.batch.key,
                                                      direction)
        return sendfile(url, buffering=False, filename='%s-%s.json' % (
            conversation.key, direction))
예제 #3
0
 def test_sendfile_streaming(self):
     resp = sendfile('/foo', buffering=False)
     self.assertEqual(resp['X-Accel-Redirect'], '/foo')
     self.assertEqual(resp['X-Accel-Buffering'], 'no')
예제 #4
0
 def test_sendfile(self):
     resp = sendfile('/foo')
     self.assertEqual(resp['X-Accel-Redirect'], '/foo')
     self.assertEqual(resp['X-Accel-Buffering'], 'yes')