

def check_path_header(req, name, length, error_msg):
    '\n    Validate that the value of path-like header is\n    well formatted. We assume the caller ensures that\n    specific header is present in req.headers.\n\n    :param req: HTTP request object\n    :param name: header name\n    :param length: length of path segment check\n    :param error_msg: error message for client\n    :returns: A tuple with path parts according to length\n    :raise: HTTPPreconditionFailed if header value\n            is not well formatted.\n    '
    src_header = unquote(req.headers.get(name))
    if (not src_header.startswith('/')):
        src_header = ('/' + src_header)
    try:
        return utils.split_path(src_header, length, length, True)
    except ValueError:
        raise HTTPPreconditionFailed(request=req, body=error_msg)

dataset/ETHPy150Open openstack/swift/swift/common/constraints.py check_path_header/original