Relax accept header for gup.pe
This commit is contained in:
parent
78d2283458
commit
4635874c12
|
@ -24,10 +24,13 @@ class JsonViewer(FormView):
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
raw_result = ""
|
raw_result = ""
|
||||||
|
uri = form.cleaned_data["uri"]
|
||||||
|
if "://" not in uri:
|
||||||
|
uri = "https://" + uri
|
||||||
try:
|
try:
|
||||||
response = async_to_sync(SystemActor().signed_request)(
|
response = async_to_sync(SystemActor().signed_request)(
|
||||||
method="get",
|
method="get",
|
||||||
uri=form.cleaned_data["uri"],
|
uri=uri,
|
||||||
)
|
)
|
||||||
except httpx.RequestError:
|
except httpx.RequestError:
|
||||||
result = "Request Error"
|
result = "Request Error"
|
||||||
|
|
|
@ -183,6 +183,8 @@ class HttpSignature:
|
||||||
Performs an async request to the given path, with a document, signed
|
Performs an async request to the given path, with a document, signed
|
||||||
as an identity.
|
as an identity.
|
||||||
"""
|
"""
|
||||||
|
if "://" not in uri:
|
||||||
|
raise ValueError("URI does not contain a scheme")
|
||||||
# Create the core header field set
|
# Create the core header field set
|
||||||
uri_parts = urlparse(uri)
|
uri_parts = urlparse(uri)
|
||||||
date_string = http_date()
|
date_string = http_date()
|
||||||
|
@ -200,9 +202,7 @@ class HttpSignature:
|
||||||
body_bytes = b""
|
body_bytes = b""
|
||||||
# GET requests get implicit accept headers added
|
# GET requests get implicit accept headers added
|
||||||
if method == "get":
|
if method == "get":
|
||||||
headers[
|
headers["Accept"] = "application/ld+json"
|
||||||
"Accept"
|
|
||||||
] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
|
|
||||||
# Sign the headers
|
# Sign the headers
|
||||||
signed_string = "\n".join(
|
signed_string = "\n".join(
|
||||||
f"{name.lower()}: {value}" for name, value in headers.items()
|
f"{name.lower()}: {value}" for name, value in headers.items()
|
||||||
|
|
Loading…
Reference in New Issue