diff --git a/tools/google_maven_proxy.py b/tools/google_maven_proxy.py index 0629ce0..af4a153 100644 --- a/tools/google_maven_proxy.py +++ b/tools/google_maven_proxy.py @@ -430,6 +430,9 @@ def _download_from_google_maven(self, request_path: str, artifact_path: Path) -> class MirrorHandler(BaseHTTPRequestHandler): mirror_index: MavenMirrorIndex + EMPTY_JAR_BYTES = ( + b"PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ) def do_GET(self) -> None: # noqa: N802 self._serve(send_body=True) @@ -499,8 +502,11 @@ def _send_bytes( @staticmethod def _synthetic_response(request_path: str) -> tuple[str, bytes] | None: marker_prefix = "com/android/application/com.android.application.gradle.plugin/" - if request_path.startswith(marker_prefix) and request_path.endswith(".pom"): - version = request_path.removeprefix(marker_prefix).split("/", 1)[0] + if not request_path.startswith(marker_prefix): + return None + + version = request_path.removeprefix(marker_prefix).split("/", 1)[0] + if request_path.endswith(".pom"): pom = f""" @@ -520,6 +526,9 @@ def _synthetic_response(request_path: str) -> tuple[str, bytes] | None: """.encode("utf-8") return "application/xml; charset=utf-8", pom + if request_path.endswith(".jar"): + return "application/java-archive", MirrorHandler.EMPTY_JAR_BYTES + return None