update mediaType observations

This commit is contained in:
a 2022-12-27 21:36:33 -06:00
parent 018a0c1c5c
commit 50e0fd11c5

View file

@ -1,6 +1,10 @@
+++
+++
{{<toc>}}
## interpretation of request/response types in as2/ap
AS2-Core says
> An Activity Streams Document is a JSON document whose root value is an Activity Streams Object of any type [...] and whose MIME media type is `application/activity+json` [...] Implementations SHOULD consider the `application/ld+json; profile="https://www.w3.org/ns/activitystreams"` media type as being equivalent to `application/activity+json`.
@ -22,6 +26,8 @@ and on the response side:
- return activity+json (regardless of request type)
## both are equivalent (and used in practice!)
HOWEVER: in practice, you will probably need to be able to handle both types in both request+response
impls that return activity+json:
@ -33,3 +39,21 @@ impls that return ld+json:
- misskey
- pixelfed
impls that POST with activity+json:
- mastodon
- ...
## gotcha: multiple types
ALSO NOTE: you may encounter multiple accept/content-type values. mastodon for example makes GET requests with `Accept: application/activity+json, application/ld+json` (in violation of the activitypub spec) or `Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams", text/html;q=0.1` (also in violation of activitypub). these are still valid by RFC 9110 "HTTP Semantics" `Accept:` header parsing rules. note that multiple types are separated by a comma (`,`) but you must not parse them in order; *you parse them by most specific type first*.
> for example:
> `Accept: text/*, text/plain, text/plain;format=flowed, */*`
> [has] the following precedence:
> 1. text/plain;format=flowed
> 2. text/plain
> 3. text/*
> 4. \*/\*