@@ -91,14 +91,13 @@ def test_simple_cache_separate_accept_headers(synced_distro):
9191
9292
9393@pytest .mark .parallel
94- def test_simple_cache_format_json_does_not_poison_html (synced_distro ):
94+ def test_simple_cache_negotiated_media_types_are_separate (synced_distro ):
9595 """
96- A ?format=json response must not poison a later request with the same Accept .
96+ JSON and HTML responses must not poison each other in the cache .
9797
98- Clients like uv/pip send an Accept that allows both JSON and HTML. DRF's
99- ?format=json overrides negotiation to JSON, while the same Accept without
100- that query param selects HTML. Caching must key on the negotiated type so
101- the JSON entry is not served (and re-rendered) for the HTML request.
98+ Clients like uv/pip send an Accept that allows both JSON and HTML. The
99+ negotiated JSON response must be cached separately from an explicit HTML
100+ response.
102101 """
103102 url = f"{ urljoin (synced_distro .base_url , 'simple/' )} aiohttp"
104103 # pip/uv-style Accept: JSON preferred, HTML still acceptable
@@ -112,13 +111,13 @@ def test_simple_cache_format_json_does_not_poison_html(synced_distro):
112111 assert r_json .headers ["X-PULP-CACHE" ] == "MISS"
113112 assert r_json .json ()["name" ] == "aiohttp"
114113
115- r_html = requests .get (url , headers = headers )
114+ r_html = requests .get (url , headers = { "Accept" : PYPI_TEXT_HTML } )
116115 assert r_html .status_code == 200
117116 assert PYPI_TEXT_HTML in r_html .headers ["Content-Type" ]
118117 assert r_html .headers ["X-PULP-CACHE" ] == "MISS"
119118 assert b"<a href=" in r_html .content
120119
121- r_html_hit = requests .get (url , headers = headers )
120+ r_html_hit = requests .get (url , headers = { "Accept" : PYPI_TEXT_HTML } )
122121 assert r_html_hit .status_code == 200
123122 assert r_html_hit .headers ["X-PULP-CACHE" ] == "HIT"
124123 assert PYPI_TEXT_HTML in r_html_hit .headers ["Content-Type" ]
0 commit comments