Skip to content

Commit

Permalink
Fix to work even if there are multiple Content-Type headers
Browse files Browse the repository at this point in the history
  • Loading branch information
suecharo committed Oct 6, 2023
1 parent e16612a commit 20528ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions schema_salad/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def fetch_text(self, url: str, content_types: Optional[List[str]] = None) -> str
except Exception as e:
raise ValidationException(f"Error fetching {url}: {e}") from e
if content_types and "content-type" in resp.headers:
content_type = resp.headers["content-type"].split(";")[:1][0]
if content_type not in content_types:
received_content_types = set(resp.headers["content-type"].split(";")[:1][0].split(","))
if set(content_types).isdisjoint(received_content_types):
_logger.warning(
"While fetching %s, got content-type of %r. Expected one of %s.",
url,
content_type,
resp.headers["content-type"].split(";")[:1][0],
content_types,
)
return resp.text
Expand Down

0 comments on commit 20528ef

Please sign in to comment.