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

Function parse_header

tools/python-3.11.9-amd64/Lib/cgi.py:238–256  ·  view source on GitHub ↗

Parse a Content-type like header. Return the main content-type and a dictionary of options.

(line)

Source from the content-addressed store, hash-verified

236 s = s[end:]
237
238def parse_header(line):
239 """Parse a Content-type like header.
240
241 Return the main content-type and a dictionary of options.
242
243 """
244 parts = _parseparam(';' + line)
245 key = parts.__next__()
246 pdict = {}
247 for p in parts:
248 i = p.find('=')
249 if i >= 0:
250 name = p[:i].strip().lower()
251 value = p[i+1:].strip()
252 if len(value) >= 2 and value[0] == value[-1] == '"':
253 value = value[1:-1]
254 value = value.replace('\\\\', '\\').replace('\\"', '"')
255 pdict[name] = value
256 return key, pdict
257
258
259# Classes for field storage

Callers 2

parseFunction · 0.85
__init__Method · 0.85

Calls 6

stripMethod · 0.80
_parseparamFunction · 0.70
__next__Method · 0.45
findMethod · 0.45
lowerMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected