mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-03-12 04:35:40 -07:00
* Bump cherrypy from 18.9.0 to 18.10.0 Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.9.0 to 18.10.0. - [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst) - [Commits](https://github.com/cherrypy/cherrypy/compare/v18.9.0...v18.10.0) --- updated-dependencies: - dependency-name: cherrypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update cherrypy==18.10.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""headers."""
|
|
|
|
|
|
def _parse_param(s):
|
|
while s[:1] == ';':
|
|
s = s[1:]
|
|
end = s.find(';')
|
|
while end > 0 and (s.count('"', 0, end) - s.count('\\"', 0, end)) % 2:
|
|
end = s.find(';', end + 1)
|
|
if end < 0:
|
|
end = len(s)
|
|
f = s[:end]
|
|
yield f.strip()
|
|
s = s[end:]
|
|
|
|
|
|
def parse_header(line):
|
|
"""Parse a Content-type like header.
|
|
|
|
Return the main content-type and a dictionary of options.
|
|
|
|
Copied from removed stdlib cgi module. See
|
|
`cherrypy/cherrypy#2014 (comment)
|
|
<https://github.com/cherrypy/cherrypy/issues/2014#issuecomment-1883774891>`_
|
|
for background.
|
|
"""
|
|
parts = _parse_param(';' + line)
|
|
key = parts.__next__()
|
|
pdict = {}
|
|
for p in parts:
|
|
i = p.find('=')
|
|
if i >= 0:
|
|
name = p[:i].strip().lower()
|
|
value = p[i + 1:].strip()
|
|
if len(value) >= 2 and value[0] == value[-1] == '"':
|
|
value = value[1:-1]
|
|
value = value.replace('\\\\', '\\').replace('\\"', '"')
|
|
pdict[name] = value
|
|
return key, pdict
|