MCPcopy Index your code
hub / github.com/python/cpython / replace_header

Method replace_header

Lib/email/message.py:589–602  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 7

set_paramMethod · 0.95
test_replace_headerMethod · 0.95
set_flagsMethod · 0.80
update_visibleMethod · 0.80
_writeMethod · 0.80
test_is_attachmentMethod · 0.80

Calls 2

lowerMethod · 0.45
header_store_parseMethod · 0.45

Tested by 3

test_replace_headerMethod · 0.76
test_is_attachmentMethod · 0.64