本文整理汇总了Python中sendfile.real_sendfile函数的典型用法代码示例。如果您正苦于以下问题:Python real_sendfile函数的具体用法?Python real_sendfile怎么用?Python real_sendfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了real_sendfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_correct_file_in_xsendfile_header
def test_correct_file_in_xsendfile_header(self):
filepath = self.ensure_file('readme.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual(filepath, response['X-Sendfile'])
示例2: test_attachment_filename
def test_attachment_filename(self):
response = real_sendfile(HttpRequest(), self._get_readme(), attachment=True, attachment_filename='tests.txt')
self.assertTrue(response is not None)
self.assertEqual('attachment; filename="tests.txt"', response['Content-Disposition'])
示例3: test_attachment_filename_unicode
def test_attachment_filename_unicode(self):
response = real_sendfile(HttpRequest(), self._get_readme(), attachment=True, attachment_filename='test’s.txt')
self.assertTrue(response is not None)
self.assertEqual('attachment; filename="test\'s.txt"; filename*=UTF-8\'\'test%E2%80%99s.txt', response['Content-Disposition'])
示例4: test_set_mimetype
def test_set_mimetype(self):
response = real_sendfile(HttpRequest(), self._get_readme(), mimetype='text/plain')
self.assertTrue(response is not None)
self.assertEqual('text/plain', response['Content-Type'])
示例5: test_set_encoding
def test_set_encoding(self):
response = real_sendfile(HttpRequest(), self._get_readme(), encoding='utf8')
self.assertTrue(response is not None)
self.assertEqual('utf8', response['Content-Encoding'])
示例6: test_404
def test_404(self):
try:
real_sendfile(HttpRequest(), 'fhdsjfhjk.txt')
except Http404:
pass
示例7: test_sendfile
def test_sendfile(self):
response = real_sendfile(HttpRequest(), self._get_readme())
self.assertTrue(response is not None)
self.assertEqual('text/plain', response['Content-Type'])
self.assertEqual(self._get_readme(), smart_str(response.content))
示例8: test_correct_url_in_xaccelredirect_header
def test_correct_url_in_xaccelredirect_header(self):
filepath = self.ensure_file('readme.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual('/private/readme.txt', response['X-Accel-Redirect'])
示例9: test_xaccelredirect_header_containing_unicode
def test_xaccelredirect_header_containing_unicode(self):
filepath = self.ensure_file(u'péter_là_gueule.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual('/private/p%C3%A9ter_l%C3%A0_gueule.txt', response['X-Accel-Redirect'])
示例10: test_correct_url_in_xaccelredirect_header
def test_correct_url_in_xaccelredirect_header(self):
response = real_sendfile(HttpRequest(), _get_readme())
self.assertTrue(response is not None)
self.assertEqual('/private/README.rst', response['X-Accel-Redirect'])
示例11: test_xsendfile_header_containing_unicode
def test_xsendfile_header_containing_unicode(self):
filepath = self.ensure_file(u'péter_là_gueule.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual(smart_str(filepath), response['X-Sendfile'])
示例12: test_correct_file_in_xsendfile_header
def test_correct_file_in_xsendfile_header(self):
response = real_sendfile(HttpRequest(), _get_readme())
self.assertTrue(response is not None)
self.assertEqual(_get_readme(), response['X-Sendfile'])
示例13: test_attachment
def test_attachment(self):
response = real_sendfile(HttpRequest(), _get_readme(), attachment=True)
self.assertTrue(response is not None)
self.assertEqual('attachment; filename="README.rst"', response['Content-Disposition'])
示例14: test_sendfile
def test_sendfile(self):
response = real_sendfile(HttpRequest(), _get_readme())
self.assertTrue(response is not None)
self.assertEqual('application/octet-stream', response['Content-Type'])
self.assertEqual(_get_readme(), response.content)
示例15: test_location_header_containing_unicode
def test_location_header_containing_unicode(self):
filepath = self.ensure_file(u'péter_là_gueule.txt')
response = real_sendfile(HttpRequest(), filepath)
self.assertTrue(response is not None)
self.assertEqual(u'/private/péter_là_gueule.txt'.encode('utf-8'), unquote(response['Location']))