'Remove all header tuples for `key` and add a new one.  The newly
added key either appears at the end of the list if there was no
entry or replaces the first one.
Keyword arguments can specify additional parameters for the header
value, with underscores converted to dashes.  See :meth:`add` for
more information.
.. versionchanged:: 0.6.1
:meth:`set` now accepts the same arguments as :meth:`add`.
:param key: The key to be inserted.
:param value: The value to be inserted.'

def set(self, _key, _value, **kw):

    if kw:
        _value = _options_header_vkw(_value, kw)
    _value = _unicodify_header_value(_value)
    self._validate_value(_value)
    if (not self._list):
        self._list.append((_key, _value))
        return
    listiter = iter(self._list)
    ikey = _key.lower()
    for (idx, (old_key, old_value)) in enumerate(listiter):
        if (old_key.lower() == ikey):
            self._list[idx] = (_key, _value)
            break
    else:
        self._list.append((_key, _value))
        return
    self._list[(idx + 1):] = [t for t in listiter if (t[0].lower() != ikey)]
