本文整理汇总了Python中werkzeug.http.parse_options_header函数的典型用法代码示例。如果您正苦于以下问题:Python parse_options_header函数的具体用法?Python parse_options_header怎么用?Python parse_options_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_options_header函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_attachment
def test_attachment(self, catch_deprecation_warnings):
app = flask.Flask(__name__)
with catch_deprecation_warnings() as captured:
with app.test_request_context():
f = open(os.path.join(app.root_path, 'static/index.html'))
rv = flask.send_file(f, as_attachment=True)
value, options = parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment'
rv.close()
# mimetypes + etag
assert len(captured) == 2
with app.test_request_context():
assert options['filename'] == 'index.html'
rv = flask.send_file('static/index.html', as_attachment=True)
value, options = parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment'
assert options['filename'] == 'index.html'
rv.close()
with app.test_request_context():
rv = flask.send_file(StringIO('Test'), as_attachment=True,
attachment_filename='index.txt',
add_etags=False)
assert rv.mimetype == 'text/plain'
value, options = parse_options_header(rv.headers['Content-Disposition'])
assert value == 'attachment'
assert options['filename'] == 'index.txt'
rv.close()
开发者ID:BobStevens,项目名称:flask,代码行数:29,代码来源:test_helpers.py
示例2: test_parse_options_header
def test_parse_options_header(self):
assert http.parse_options_header('something; foo="other\"thing"') == \
('something', {'foo': 'other"thing'})
assert http.parse_options_header('something; foo="other\"thing"; meh=42') == \
('something', {'foo': 'other"thing', 'meh': '42'})
assert http.parse_options_header('something; foo="other\"thing"; meh=42; bleh') == \
('something', {'foo': 'other"thing', 'meh': '42', 'bleh': None})
开发者ID:0xJCG,项目名称:dubtrack-technical-test,代码行数:7,代码来源:http.py
示例3: test_attachment
def test_attachment(self):
app = flask.Flask(__name__)
with catch_warnings() as captured:
with app.test_request_context():
f = open(os.path.join(app.root_path, "static/index.html"))
rv = flask.send_file(f, as_attachment=True)
value, options = parse_options_header(rv.headers["Content-Disposition"])
self.assert_equal(value, "attachment")
rv.close()
# mimetypes + etag
self.assert_equal(len(captured), 2)
with app.test_request_context():
self.assert_equal(options["filename"], "index.html")
rv = flask.send_file("static/index.html", as_attachment=True)
value, options = parse_options_header(rv.headers["Content-Disposition"])
self.assert_equal(value, "attachment")
self.assert_equal(options["filename"], "index.html")
rv.close()
with app.test_request_context():
rv = flask.send_file(StringIO("Test"), as_attachment=True, attachment_filename="index.txt", add_etags=False)
self.assert_equal(rv.mimetype, "text/plain")
value, options = parse_options_header(rv.headers["Content-Disposition"])
self.assert_equal(value, "attachment")
self.assert_equal(options["filename"], "index.txt")
rv.close()
开发者ID:huiwq1990,项目名称:3gqq,代码行数:27,代码来源:helpers.py
示例4: test_parse_options_header_value_with_quotes
def test_parse_options_header_value_with_quotes(self):
assert http.parse_options_header(
'form-data; name="file"; filename="t\'es\'t.txt"'
) == ('form-data', {'name': 'file', 'filename': "t'es't.txt"})
assert http.parse_options_header(
'form-data; name="file"; filename*=UTF-8\'\'"\'
|
请发表评论