MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / add_header

Method add_header

tools/python-3.11.9-amd64/Lib/email/message.py:543–571  ·  view source on GitHub ↗

Extended header setting. name is the header field to add. keyword arguments can be used to set additional parameters for the header field, with underscores converted to dashes. Normally the parameter will be added as key="value" unless value is None, in which

(self, _name, _value, **_params)

Source from the content-addressed store, hash-verified

541 return values
542
543 def add_header(self, _name, _value, **_params):
544 """Extended header setting.
545
546 name is the header field to add. keyword arguments can be used to set
547 additional parameters for the header field, with underscores converted
548 to dashes. Normally the parameter will be added as key="value" unless
549 value is None, in which case only the key will be added. If a
550 parameter value contains non-ASCII characters it can be specified as a
551 three-tuple of (charset, language, value), in which case it will be
552 encoded according to RFC2231 rules. Otherwise it will be encoded using
553 the utf-8 charset and a language of ''.
554
555 Examples:
556
557 msg.add_header('content-disposition', 'attachment', filename='bud.gif')
558 msg.add_header('content-disposition', 'attachment',
559 filename=('utf-8', '', Fußballer.ppt'))
560 msg.add_header('content-disposition', 'attachment',
561 filename='Fußballer.ppt'))
562 """
563 parts = []
564 for k, v in _params.items():
565 if v is None:
566 parts.append(k.replace('_', '-'))
567 else:
568 parts.append(_formatparam(k.replace('_', '-'), v))
569 if _value is not None:
570 parts.insert(0, _value)
571 self[_name] = SEMISPACE.join(parts)
572
573 def replace_header(self, _name, _value):
574 """Replace a header.

Callers 3

set_charsetMethod · 0.95
set_flagsMethod · 0.45
__init__Method · 0.45

Calls 6

_formatparamFunction · 0.70
itemsMethod · 0.45
appendMethod · 0.45
replaceMethod · 0.45
insertMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected