

def quote_header_value(value, extra_chars='', allow_token=True):
    'Quote a header value if necessary.\n\n    .. versionadded:: 0.5\n\n    :param value: the value to quote.\n    :param extra_chars: a list of extra characters to skip quoting.\n    :param allow_token: if this is enabled token values are returned\n                        unchanged.\n    '
    if isinstance(value, bytes):
        value = bytes_to_wsgi(value)
    value = str(value)
    if allow_token:
        token_chars = (_token_chars | set(extra_chars))
        if set(value).issubset(token_chars):
            return value
    return ('"%s"' % value.replace('\\', '\\\\').replace('"', '\\"'))

dataset/ETHPy150Open Eforcers/gae-flask-todo/lib/werkzeug/http.py quote_header_value/original