Relax accept header for gup.pe

This commit is contained in:
Andrew Godwin 2022-12-20 13:21:36 +00:00
parent 78d2283458
commit 4635874c12
2 changed files with 7 additions and 4 deletions

View File

@ -24,10 +24,13 @@ class JsonViewer(FormView):
def form_valid(self, form):
raw_result = ""
uri = form.cleaned_data["uri"]
if "://" not in uri:
uri = "https://" + uri
try:
response = async_to_sync(SystemActor().signed_request)(
method="get",
uri=form.cleaned_data["uri"],
uri=uri,
)
except httpx.RequestError:
result = "Request Error"

View File

@ -183,6 +183,8 @@ class HttpSignature:
Performs an async request to the given path, with a document, signed
as an identity.
"""
if "://" not in uri:
raise ValueError("URI does not contain a scheme")
# Create the core header field set
uri_parts = urlparse(uri)
date_string = http_date()
@ -200,9 +202,7 @@ class HttpSignature:
body_bytes = b""
# GET requests get implicit accept headers added
if method == "get":
headers[
"Accept"
] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
headers["Accept"] = "application/ld+json"
# Sign the headers
signed_string = "\n".join(
f"{name.lower()}: {value}" for name, value in headers.items()