• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python http.parse_options_header函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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\'\'"\' 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python http.parse_set_header函数代码示例发布时间:2022-05-26
下一篇:
Python http.parse_dict_header函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap