From d247baa307b0065fdaa92ab6694cffee5f4db4e4 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 30 Dec 2022 10:12:48 -0700 Subject: [PATCH] Serve webfinger and host-meta with correct mimetypes Fixes #323 (hopefully!) --- tests/users/views/test_activitypub.py | 4 +++- users/views/activitypub.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/users/views/test_activitypub.py b/tests/users/views/test_activitypub.py index c15e232..9bde51f 100644 --- a/tests/users/views/test_activitypub.py +++ b/tests/users/views/test_activitypub.py @@ -8,7 +8,9 @@ def test_webfinger_actor(client, identity): """ identity.generate_keypair() # 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["aliases"][0] == "https://example.com/@test/" # Fetch their actor diff --git a/users/views/activitypub.py b/users/views/activitypub.py index 985a00e..774901b 100644 --- a/users/views/activitypub.py +++ b/users/views/activitypub.py @@ -41,7 +41,7 @@ class HostMeta(View): """ % request.headers["host"], - content_type="application/xml", + content_type="application/xrd+xml", ) @@ -110,7 +110,7 @@ class Webfinger(View): else: 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")