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, '')
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))
def test_sendfile_streaming(self): resp = sendfile('/foo', buffering=False) self.assertEqual(resp['X-Accel-Redirect'], '/foo') self.assertEqual(resp['X-Accel-Buffering'], 'no')
def test_sendfile(self): resp = sendfile('/foo') self.assertEqual(resp['X-Accel-Redirect'], '/foo') self.assertEqual(resp['X-Accel-Buffering'], 'yes')