MCPcopy Index your code
hub / github.com/RustPython/RustPython / add_header

Method add_header

Lib/wsgiref/headers.py:157–184  ·  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 case

(self, _name, _value, **_params)

Source from the content-addressed store, hash-verified

155 return result
156
157 def add_header(self, _name, _value, **_params):
158 """Extended header setting.
159
160 _name is the header field to add. keyword arguments can be used to set
161 additional parameters for the header field, with underscores converted
162 to dashes. Normally the parameter will be added as key="value" unless
163 value is None, in which case only the key will be added.
164
165 Example:
166
167 h.add_header('content-disposition', 'attachment', filename='bud.gif')
168
169 Note that unlike the corresponding 'email.message' method, this does
170 *not* handle '(charset, language, value)' tuples: all values must be
171 strings or None.
172 """
173 parts = []
174 if _value is not None:
175 _value = self._convert_string_type(_value)
176 parts.append(_value)
177 for k, v in _params.items():
178 k = self._convert_string_type(k)
179 if v is None:
180 parts.append(k.replace('_', '-'))
181 else:
182 v = self._convert_string_type(v)
183 parts.append(_formatparam(k.replace('_', '-'), v))
184 self._headers.append((self._convert_string_type(_name), "; ".join(parts)))

Callers 1

testExtrasMethod · 0.95

Calls 6

_convert_string_typeMethod · 0.95
_formatparamFunction · 0.70
appendMethod · 0.45
itemsMethod · 0.45
replaceMethod · 0.45
joinMethod · 0.45

Tested by 1

testExtrasMethod · 0.76