Replace a header. Replace the first matching header found in the message, retaining header order and case. If no matching header was found, a KeyError is raised.
(self, _name, _value)
| 587 | self[_name] = SEMISPACE.join(parts) |
| 588 | |
| 589 | def replace_header(self, _name, _value): |
| 590 | """Replace a header. |
| 591 | |
| 592 | Replace the first matching header found in the message, retaining |
| 593 | header order and case. If no matching header was found, a KeyError is |
| 594 | raised. |
| 595 | """ |
| 596 | _name = _name.lower() |
| 597 | for i, (k, v) in zip(range(len(self._headers)), self._headers): |
| 598 | if k.lower() == _name: |
| 599 | self._headers[i] = self.policy.header_store_parse(k, _value) |
| 600 | break |
| 601 | else: |
| 602 | raise KeyError(_name) |
| 603 | |
| 604 | # |
| 605 | # Use these three methods instead of the three above. |