diff --git a/content/tech/activitypub/!media-type.md b/content/tech/activitypub/!media-type.md index 42d5296..1f41e89 100644 --- a/content/tech/activitypub/!media-type.md +++ b/content/tech/activitypub/!media-type.md @@ -1,6 +1,10 @@ +++ +++ +{{}} + +## 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: @@ -32,4 +38,22 @@ impls that return activity+json: impls that return ld+json: - misskey -- pixelfed \ No newline at end of file +- 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. \*/\* +