我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用werkzeug.http.parse_set_header()。
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'])
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'])
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')