From 404448f6d7baa30a2a59abbadbc1df61fc980f62 Mon Sep 17 00:00:00 2001 From: pmasko Date: Mon, 16 Dec 2024 12:46:59 +0100 Subject: [PATCH] Fix CGI dependancy for Python 3.11 < --- json_ref_dict/loader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/json_ref_dict/loader.py b/json_ref_dict/loader.py index b9c20a1..0b7da2f 100644 --- a/json_ref_dict/loader.py +++ b/json_ref_dict/loader.py @@ -1,4 +1,4 @@ -import cgi +from email.message import Message import os import pathlib import posixpath @@ -139,7 +139,10 @@ def _get_content_type(conn) -> str: content_type = mimetypes.guess_type(conn.url)[0] or "" if hasattr(conn, "getheaders"): content_type = dict(conn.getheaders()).get("Content-Type", content_type) - return cgi.parse_header(content_type)[0] + + msg = Message() + msg['content-type'] = content_type + return msg.get_content_type() # Can possibly be hotswitched by patching.