code: def quote_header_value(value, extra_chars='', allow_token=True):
      
      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('"', '\\"')
docs: Quote a header value if necessary.
  
      .. versionadded:: 0.5
  
      :param value: the value to quote.
      :param extra_chars: a list of extra characters to skip quoting.
      :param allow_token: if this is enabled token values are returned
                          unchanged.