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


Python werkzeug.http方法代码示例

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


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

示例1: deserialize

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def deserialize(expected_content_types=None):
    if expected_content_types is None:
        expected_content_types = ("application/json", )

    mime_type, options = werkzeug.http.parse_options_header(
        pecan.request.headers.get('Content-Type'))
    if mime_type not in expected_content_types:
        abort(415)
    try:
        params = json.load(pecan.request.body_file)
    except Exception as e:
        details = rest_exceptions.UnableToDecodeBody(e,
                                                     pecan.request.body_file)
        LOG.warning(details.jsonify())
        abort(400, details)
    return params 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:18,代码来源:api.py

示例2: get_current_user

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def get_current_user(request):
        auth = werkzeug.http.parse_authorization_header(
            request.headers.get("Authorization"))
        if auth is None:
            api.abort(401)
        return auth.username 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:8,代码来源:auth_helper.py

示例3: abort

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def abort(status_code, detail=''):
    """Like pecan.abort, but make sure detail is a string."""
    if status_code == 404 and not detail:
        raise RuntimeError("http code 404 must have 'detail' set")

    if isinstance(detail, voluptuous.Invalid):
        detail = {
            'cause': 'Invalid input',
            'reason': six.text_type(detail),
            'detail': [six.text_type(path) for path in detail.path],
        }
    elif isinstance(detail, Exception):
        detail = detail.jsonify()
    LOG.debug("Aborting request. Code [%s]. Details [%s]", status_code, detail)
    return pecan.abort(status_code, detail) 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:17,代码来源:api.py

示例4: set_resp_location_hdr

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def set_resp_location_hdr(location):
    location = '%s%s' % (pecan.request.script_name, location)
    # NOTE(sileht): according the pep-3333 the headers must be
    # str in py2 and py3 even this is not the same thing in both
    # version
    # see: http://legacy.python.org/dev/peps/pep-3333/#unicode-issues
    if six.PY2 and isinstance(location, six.text_type):
        location = location.encode('utf-8')
    location = urllib_parse.quote(location)
    pecan.response.headers['Location'] = location 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:12,代码来源:api.py

示例5: __init__

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def __init__(self, valid_methods=None, description=None):
        """Takes an optional list of valid http methods
        starting with werkzeug 0.3 the list will be mandatory."""
        HTTPException.__init__(self, description)
        self.valid_methods = valid_methods 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:exceptions.py

示例6: _get_basic_authenticator

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def _get_basic_authenticator(req):
        auth = werkzeug.http.parse_authorization_header(
            req.headers.get("Authorization"))
        return auth 
开发者ID:openstack,项目名称:vitrage,代码行数:6,代码来源:basic_and_keystone_auth.py

示例7: test_old_imports

# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import http [as 别名]
def test_old_imports(self):
        from werkzeug.utils import Headers, MultiDict, CombinedMultiDict, \
             Headers, EnvironHeaders
        from werkzeug.http import Accept, MIMEAccept, CharsetAccept, \
             LanguageAccept, ETags, HeaderSet, WWWAuthenticate, \
             Authorization 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:8,代码来源:compat.py


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