当前位置: 首页>>代码示例>>Python>>正文


Python http.parse_set_header函数代码示例

本文整理汇总了Python中werkzeug.http.parse_set_header函数的典型用法代码示例。如果您正苦于以下问题:Python parse_set_header函数的具体用法?Python parse_set_header怎么用?Python parse_set_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_set_header函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fget

 def fget(self):
     def on_update(header_set):
         if not header_set and name in self.headers:
             del self.headers[name]
         elif header_set:
             self.headers[name] = header_set.to_header()
     return parse_set_header(self.headers.get(name), on_update)
开发者ID:danaspiegel,项目名称:softball_stat_manager,代码行数:7,代码来源:wrappers.py

示例2: fix_headers

    def fix_headers(self, environ, headers, status=None):
        if self.fix_vary:
            header = headers.get("content-type", "")
            mimetype, options = parse_options_header(header)
            if mimetype not in ("text/html", "text/plain", "text/sgml"):
                headers.pop("vary", None)

        if self.fix_attach and "content-disposition" in headers:
            pragma = parse_set_header(headers.get("pragma", ""))
            pragma.discard("no-cache")
            header = pragma.to_header()
            if not header:
                headers.pop("pragma", "")
            else:
                headers["Pragma"] = header
            header = headers.get("cache-control", "")
            if header:
                cc = parse_cache_control_header(header, cls=ResponseCacheControl)
                cc.no_cache = None
                cc.no_store = False
                header = cc.to_header()
                if not header:
                    headers.pop("cache-control", "")
                else:
                    headers["Cache-Control"] = header
开发者ID:jrgrafton,项目名称:tweet-debate,代码行数:25,代码来源:fixers.py

示例3: fix_headers

    def fix_headers(self, environ, headers, status=None):
        if self.fix_vary:
            header = headers.get('content-type', '')
            mimetype, options = parse_options_header(header)
            if mimetype not in ('text/html', 'text/plain', 'text/sgml'):
                headers.pop('vary', None)

        if self.fix_attach and 'content-disposition' in headers:
            pragma = parse_set_header(headers.get('pragma', ''))
            pragma.discard('no-cache')
            header = pragma.to_header()
            if not header:
                headers.pop('pragma', '')
            else:
                headers['Pragma'] = header
            header = headers.get('cache-control', '')
            if header:
                cc = parse_cache_control_header(header,
                                                cls=ResponseCacheControl)
                cc.no_cache = None
                cc.no_store = False
                header = cc.to_header()
                if not header:
                    headers.pop('cache-control', '')
                else:
                    headers['Cache-Control'] = header
开发者ID:gaoussoucamara,项目名称:simens-cerpad,代码行数:26,代码来源:fixers.py

示例4: common_asserts

def common_asserts(app):
    c = app.test_client()
    assert c.get('/').data == b'GET'
    assert c.post('/').data == b'POST'
    assert c.put('/').status_code == 405
    meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
    assert sorted(meths) == ['GET', 'HEAD', 'OPTIONS', 'POST']
开发者ID:avdd,项目名称:flak,代码行数:7,代码来源:test_views.py

示例5: common_test

    def common_test(self, app):
        c = app.test_client()

        self.assert_equal(c.get("/").data, b"GET")
        self.assert_equal(c.post("/").data, b"POST")
        self.assert_equal(c.put("/").status_code, 405)
        meths = parse_set_header(c.open("/", method="OPTIONS").headers["Allow"])
        self.assert_equal(sorted(meths), ["GET", "HEAD", "OPTIONS", "POST"])
开发者ID:42only,项目名称:flask,代码行数:8,代码来源:views.py

示例6: common_test

def common_test(app):
    c = app.test_client()

    assert c.get("/").data == b"GET"
    assert c.post("/").data == b"POST"
    assert c.put("/").status_code == 405
    meths = parse_set_header(c.open("/", method="OPTIONS").headers["Allow"])
    assert sorted(meths) == ["GET", "HEAD", "OPTIONS", "POST"]
开发者ID:guyskk,项目名称:flask,代码行数:8,代码来源:test_views.py

示例7: test_set_header

 def test_set_header(self):
     hs = http.parse_set_header('foo, Bar, "Blah baz", Hehe')
     self.assert_true('blah baz' in hs)
     self.assert_true('foobar' not in hs)
     self.assert_true('foo' in hs)
     self.assert_equal(list(hs), ['foo', 'Bar', 'Blah baz', 'Hehe'])
     hs.add('Foo')
     self.assert_equal(hs.to_header(), 'foo, Bar, "Blah baz", Hehe')
开发者ID:211sandiego,项目名称:calllog211,代码行数:8,代码来源:http.py

示例8: test_set_header

 def test_set_header(self):
     hs = http.parse_set_header('foo, Bar, "Blah baz", Hehe')
     assert 'blah baz' in hs
     assert 'foobar' not in hs
     assert 'foo' in hs
     assert list(hs) == ['foo', 'Bar', 'Blah baz', 'Hehe']
     hs.add('Foo')
     assert hs.to_header() == 'foo, Bar, "Blah baz", Hehe'
开发者ID:TomCorwine,项目名称:werkzeug,代码行数:8,代码来源:test_http.py

示例9: qop

    def qop(self):

        def on_update(header_set):
            if not header_set and 'qop' in self:
                del self['qop']
            elif header_set:
                self['qop'] = header_set.to_header()

        return parse_set_header(self.get('qop'), on_update)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:9,代码来源:datastructures.py

示例10: test_view_inheritance

def test_view_inheritance(app, client):
    class Index(flask.views.MethodView):
        def get(self):
            return "GET"

        def post(self):
            return "POST"

    class BetterIndex(Index):
        def delete(self):
            return "DELETE"

    app.add_url_rule("/", view_func=BetterIndex.as_view("index"))

    meths = parse_set_header(client.open("/", method="OPTIONS").headers["Allow"])
    assert sorted(meths) == ["DELETE", "GET", "HEAD", "OPTIONS", "POST"]
开发者ID:Warkanlock,项目名称:flask,代码行数:16,代码来源:test_views.py

示例11: test_view_inheritance

    def test_view_inheritance(self):
        app = flask.Flask(__name__)

        class Index(flask.views.MethodView):
            def get(self):
                return 'GET'
            def post(self):
                return 'POST'

        class BetterIndex(Index):
            def delete(self):
                return 'DELETE'

        app.add_url_rule('/', view_func=BetterIndex.as_view('index'))
        c = app.test_client()

        meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
        self.assert_equal(sorted(meths), ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST'])
开发者ID:rosudrag,项目名称:Freemium-winner,代码行数:18,代码来源:views.py

示例12: pragma

 def pragma(self):
     return parse_set_header(self.environ.get('HTTP_PRAGMA', ''))
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:2,代码来源:wrappers.py

示例13: pragma

 def pragma(self):
     return parse_set_header(self.environ.get("HTTP_PRAGMA", ""))
开发者ID:Reve,项目名称:eve,代码行数:2,代码来源:wrappers.py


注:本文中的werkzeug.http.parse_set_header函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。