Skip to content

Commit

Permalink
Use a tuple and one call to startswith
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Jul 15, 2022
1 parent 1fc571f commit a287a0b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pip/_internal/index/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def _ensure_api_header(response: Response) -> None:
content_type = response.headers.get("Content-Type", "")

content_type_l = content_type.lower()
if content_type_l.startswith("text/html"):
return
elif content_type_l.startswith("application/vnd.pypi.simple.v1+html"):
return
elif content_type_l.startswith("application/vnd.pypi.simple.v1+json"):
if content_type_l.startswith(
(
"text/html",
"application/vnd.pypi.simple.v1+html",
"application/vnd.pypi.simple.v1+json",
)
):
return

raise _NotAPIContent(content_type, response.request.method)
Expand Down

0 comments on commit a287a0b

Please sign in to comment.