Resolve "Support browsing a specific library content"

This commit is contained in:
Eliot Berriot 2020-03-04 22:18:28 +01:00
parent ecc3ed3ac3
commit b166182762
47 changed files with 1020 additions and 336 deletions

View file

@ -201,3 +201,26 @@ def find_alternate(response_text):
parser.feed(response_text)
except StopParsing:
return parser.result
def should_redirect_ap_to_html(accept_header):
if not accept_header:
return False
redirect_headers = [
"text/html",
]
no_redirect_headers = [
"application/json",
"application/activity+json",
"application/ld+json",
]
parsed_header = [ct.lower().strip() for ct in accept_header.split(",")]
for ct in parsed_header:
if ct in redirect_headers:
return True
if ct in no_redirect_headers:
return False
return True