<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def header(self, k, v, replace=True):
 """ Sets header value. Replaces existing value if `replace` is True. Otherwise create a list of existing values and `v` :param k: Header key :param v: Header value :param replace: flag for setting mode. :type k: str :type v: str :type replace: bool """

        if replace:
            self._headers[k] = [v]

        else:
            self._headers.setdefault(k, []).append(v)

        return self