From 31b6582663cf560b4d81b2f8aa2063a440910bda Mon Sep 17 00:00:00 2001 From: MiaowFISH Date: Mon, 27 Oct 2025 20:16:32 +0800 Subject: [PATCH 1/4] fix: make content-type checking more flexible for PyPI mirrors --- micropip/package_index.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/micropip/package_index.py b/micropip/package_index.py index b433a26..38c3b5d 100644 --- a/micropip/package_index.py +++ b/micropip/package_index.py @@ -250,16 +250,14 @@ def _select_parser( """ Select the function to parse the response based on the content type. """ - match content_type: + main_content_type = content_type.split(';')[0].strip() + + match main_content_type: case "application/vnd.pypi.simple.v1+json": return ProjectInfo.from_simple_json_api case "application/json": return ProjectInfo.from_json_api - case ( - "application/vnd.pypi.simple.v1+html" - | "text/html" - | "text/html; charset=utf-8" - ): + case "application/vnd.pypi.simple.v1+html" | "text/html": return partial( ProjectInfo.from_simple_html_api, pkgname=pkgname, From 25f79481d1b2aa18881fecbdf551eced2eecdbbd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Oct 2025 12:24:55 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- micropip/package_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropip/package_index.py b/micropip/package_index.py index 38c3b5d..b87f143 100644 --- a/micropip/package_index.py +++ b/micropip/package_index.py @@ -250,8 +250,8 @@ def _select_parser( """ Select the function to parse the response based on the content type. """ - main_content_type = content_type.split(';')[0].strip() - + main_content_type = content_type.split(";")[0].strip() + match main_content_type: case "application/vnd.pypi.simple.v1+json": return ProjectInfo.from_simple_json_api From 26a27afec0a098814cf4b2faa9b1c5ec68ee18cc Mon Sep 17 00:00:00 2001 From: MiaowFISH Date: Thu, 30 Oct 2025 01:49:42 +0800 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 040a56b..42341a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- Fixed content-type header parsing to handle PyPI mirrors that include charset parameters. + This improves compatibility with mirrors that return headers like 'application/json; charset=utf-8'. + [#261](https://github.com/pyodide/micropip/pull/261) + ## [0.11.0] - 2025/10/18 ### Added From f49c31e8653b66806d2c4d95d74fb3d8a5d6cdc4 Mon Sep 17 00:00:00 2001 From: MiaowFISH Date: Thu, 30 Oct 2025 01:51:44 +0800 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42341a1..08b22c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed content-type header parsing to handle PyPI mirrors that include charset parameters. - This improves compatibility with mirrors that return headers like 'application/json; charset=utf-8'. + This improves compatibility with mirrors that return headers like `application/json; charset=utf-8`. [#261](https://github.com/pyodide/micropip/pull/261) ## [0.11.0] - 2025/10/18