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

Method header_store_parse

Lib/email/policy.py:137–155  ·  view source on GitHub ↗

+ The name is returned unchanged. If the input value has a 'name' attribute and it matches the name ignoring case, the value is returned unchanged. Otherwise the name and value are passed to header_factory method, and the resulting custom header object is returned a

(self, name, value)

Source from the content-addressed store, hash-verified

135 return (name, value.rstrip('\r\n'))
136
137 def header_store_parse(self, name, value):
138 """+
139 The name is returned unchanged. If the input value has a 'name'
140 attribute and it matches the name ignoring case, the value is returned
141 unchanged. Otherwise the name and value are passed to header_factory
142 method, and the resulting custom header object is returned as the
143 value. In this case a ValueError is raised if the input value contains
144 CR or LF characters.
145
146 """
147 validate_header_name(name)
148 if hasattr(value, 'name') and value.name.lower() == name.lower():
149 return (name, value)
150 if isinstance(value, str) and len(value.splitlines())>1:
151 # XXX this error message isn't quite right when we use splitlines
152 # (see issue 22233), but I'm not sure what should happen here.
153 raise ValueError("Header values may not contain linefeed "
154 "or carriage return characters")
155 return (name, self.header_factory(name, value))
156
157 def header_fetch_parse(self, name, value):
158 """+

Callers 3

__setitem__Method · 0.45
replace_headerMethod · 0.45
set_boundaryMethod · 0.45

Calls 3

validate_header_nameFunction · 0.90
lowerMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected