tornado-openapi3/tornado_openapi3/util.py
Correl Roush 513166456a Parse mimetype from content-type
OpenAPI objects expect lowercased mimetypes, with parameters stripped.
2021-01-13 14:33:39 -05:00

10 lines
311 B
Python

import ietfparse.headers
def parse_mimetype(content_type: str) -> str:
parsed = ietfparse.headers.parse_content_type(content_type)
return "{}/{}{}".format(
parsed.content_type,
parsed.content_subtype,
"+{}".format(parsed.content_suffix) if parsed.content_suffix else "",
)