Serve webfinger and host-meta with correct mimetypes

Fixes #323 (hopefully!)
This commit is contained in:
Andrew Godwin 2022-12-30 10:12:48 -07:00
parent 75c17c0766
commit d247baa307
2 changed files with 5 additions and 3 deletions

View file

@ -8,7 +8,9 @@ def test_webfinger_actor(client, identity):
""" """
identity.generate_keypair() identity.generate_keypair()
# Fetch their webfinger # Fetch their webfinger
data = client.get("/.well-known/webfinger?resource=acct:test@example.com").json() response = client.get("/.well-known/webfinger?resource=acct:test@example.com")
assert response.headers["content-type"] == "application/jrd+json"
data = response.json()
assert data["subject"] == "acct:test@example.com" assert data["subject"] == "acct:test@example.com"
assert data["aliases"][0] == "https://example.com/@test/" assert data["aliases"][0] == "https://example.com/@test/"
# Fetch their actor # Fetch their actor

View file

@ -41,7 +41,7 @@ class HostMeta(View):
<Link rel="lrdd" template="https://%s/.well-known/webfinger?resource={uri}"/> <Link rel="lrdd" template="https://%s/.well-known/webfinger?resource={uri}"/>
</XRD>""" </XRD>"""
% request.headers["host"], % request.headers["host"],
content_type="application/xml", content_type="application/xrd+xml",
) )
@ -110,7 +110,7 @@ class Webfinger(View):
else: else:
actor = by_handle_or_404(request, handle) actor = by_handle_or_404(request, handle)
return JsonResponse(actor.to_webfinger()) return JsonResponse(actor.to_webfinger(), content_type="application/jrd+json")
@method_decorator(csrf_exempt, name="dispatch") @method_decorator(csrf_exempt, name="dispatch")