From 457f4770ec7242838065a675ed4d805dfbf764ed Mon Sep 17 00:00:00 2001 From: Gerrod Date: Mon, 23 Sep 2024 09:40:17 -0400 Subject: [PATCH] Revert "Fix URL encoding issue in HttpDownloader to handle special characters" This reverts commit d32580d3180917636a80b8c0f1052ef0d29337df. --- CHANGES/5686.bugfix | 1 - pulp_file/pytest_plugin.py | 10 ---------- pulp_file/tests/functional/api/test_sync.py | 15 --------------- pulpcore/download/http.py | 12 +----------- pulpcore/pytest_plugin.py | 11 +---------- 5 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 CHANGES/5686.bugfix diff --git a/CHANGES/5686.bugfix b/CHANGES/5686.bugfix deleted file mode 100644 index 7fd4aacb3a..0000000000 --- a/CHANGES/5686.bugfix +++ /dev/null @@ -1 +0,0 @@ -Implemented a more robust URL encoding mechanism ensuring that special characters are processed correctly. diff --git a/pulp_file/pytest_plugin.py b/pulp_file/pytest_plugin.py index 50a9428465..92f2c159e1 100644 --- a/pulp_file/pytest_plugin.py +++ b/pulp_file/pytest_plugin.py @@ -101,16 +101,6 @@ def basic_manifest_path(write_3_iso_file_fixture_data_factory): return write_3_iso_file_fixture_data_factory("basic") -@pytest.fixture -def encoded_manifest_path(file_fixtures_root): - file_fixtures_root.joinpath("encoded").mkdir() - file1 = generate_iso(file_fixtures_root.joinpath("encoded/long-name-%253a-encoded.iso")) - file2 = generate_iso(file_fixtures_root.joinpath("encoded/another-%25-encoded.iso")) - file3 = generate_iso(file_fixtures_root.joinpath("encoded/more-%3C-encoded.iso")) - generate_manifest(file_fixtures_root.joinpath("encoded/PULP_MANIFEST"), [file1, file2, file3]) - return "/encoded/PULP_MANIFEST" - - @pytest.fixture def copy_manifest_only_factory(file_fixtures_root): def _copy_manifest_only(name): diff --git a/pulp_file/tests/functional/api/test_sync.py b/pulp_file/tests/functional/api/test_sync.py index aab0d0b285..37e255da68 100644 --- a/pulp_file/tests/functional/api/test_sync.py +++ b/pulp_file/tests/functional/api/test_sync.py @@ -123,21 +123,6 @@ def test_duplicate_file_sync( assert file_repo.latest_version_href.endswith("/2/") -@pytest.mark.parallel -def test_encoded_file_name( - file_repo, file_bindings, encoded_manifest_path, file_remote_factory, monitor_task -): - remote = file_remote_factory(manifest_path=encoded_manifest_path, policy="immediate") - body = RepositorySyncURL(remote=remote.pulp_href) - monitor_task(file_bindings.RepositoriesFileApi.sync(file_repo.pulp_href, body).task) - file_repo = file_bindings.RepositoriesFileApi.read(file_repo.pulp_href) - - version = file_bindings.RepositoriesFileVersionsApi.read(file_repo.latest_version_href) - assert version.content_summary.present["file.file"]["count"] == 3 - assert version.content_summary.added["file.file"]["count"] == 3 - assert file_repo.latest_version_href.endswith("/1/") - - @pytest.mark.parallel def test_filepath_includes_commas( file_bindings, diff --git a/pulpcore/download/http.py b/pulpcore/download/http.py index 4cae3ed581..1c5c5dfa46 100644 --- a/pulpcore/download/http.py +++ b/pulpcore/download/http.py @@ -3,7 +3,6 @@ import aiohttp import asyncio import backoff -import urllib.parse from .base import BaseDownloader, DownloadResult from pulpcore.exceptions import ( @@ -50,14 +49,6 @@ def http_giveup_handler(exc): return False -def encode_url(url): - """Helper function to encode only the path part of the URL.""" - parsed_url = urllib.parse.urlparse(url) - encoded_path = urllib.parse.quote(parsed_url.path) - encoded_url = parsed_url._replace(path=encoded_path).geturl() - return encoded_url - - class HttpDownloader(BaseDownloader): """ An HTTP/HTTPS Downloader built on `aiohttp`. @@ -293,9 +284,8 @@ async def _run(self, extra_data=None): """ if self.download_throttler: await self.download_throttler.acquire() - encoded_url = encode_url(self.url) async with self.session.get( - encoded_url, proxy=self.proxy, proxy_auth=self.proxy_auth, auth=self.auth + self.url, proxy=self.proxy, proxy_auth=self.proxy_auth, auth=self.auth ) as response: self.raise_for_status(response) to_return = await self._handle_response(response) diff --git a/pulpcore/pytest_plugin.py b/pulpcore/pytest_plugin.py index 1f400200cc..2401d8be98 100644 --- a/pulpcore/pytest_plugin.py +++ b/pulpcore/pytest_plugin.py @@ -10,7 +10,6 @@ import subprocess import threading import uuid -import urllib.parse import pytest @@ -322,21 +321,13 @@ def _gen_threaded_aiohttp_server(app, ssl_ctx, call_record): @pytest.fixture def gen_fixture_server(gen_threaded_aiohttp_server): def _gen_fixture_server(fixtures_root, ssl_ctx): - app = web.Application(middlewares=[_aiohttp_request_middleware]) + app = web.Application() call_record = add_recording_route(app, fixtures_root) return gen_threaded_aiohttp_server(app, ssl_ctx, call_record) yield _gen_fixture_server -@web.middleware -async def _aiohttp_request_middleware(request, handler): - unquoted_url = urllib.parse.unquote(request.url.human_repr()) - url = urllib.parse.urlparse(unquoted_url) - response = await handler(request.clone(rel_url=url.path)) - return response - - # Proxy Fixtures