本文整理汇总了Python中wpull.protocol.http.request.Response.fields['Content-Disposition']方法的典型用法代码示例。如果您正苦于以下问题:Python Response.fields['Content-Disposition']方法的具体用法?Python Response.fields['Content-Disposition']怎么用?Python Response.fields['Content-Disposition']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpull.protocol.http.request.Response
的用法示例。
在下文中一共展示了Response.fields['Content-Disposition']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_content_disposition
# 需要导入模块: from wpull.protocol.http.request import Response [as 别名]
# 或者: from wpull.protocol.http.request.Response import fields['Content-Disposition'] [as 别名]
def test_content_disposition(self):
writer = AntiClobberFileWriter(self.get_path_namer(), content_disposition=True)
test_data = [
('hello1.txt', 'hello1.txt'),
('hello2.txt;', 'hello2.txt'),
('"hello3.txt"', 'hello3.txt'),
('\'hello4.txt\'', 'hello4.txt'),
]
for raw_filename, filename in test_data:
session = writer.session()
request = HTTPRequest('http://example.com')
response = HTTPResponse(status_code=200, reason='OK', request=request)
response.fields['Content-Disposition'] = 'attachment; filename={}'.format(raw_filename)
session.process_request(request)
session.process_response(response)
session.save_document(response)
print(list(os.walk('.')))
self.assertTrue(os.path.exists(filename))