better/simpler accept-header handling
This commit is contained in:
parent
9fd551f07d
commit
0337b78fef
1 changed files with 9 additions and 6 deletions
|
@ -54,17 +54,20 @@ class Activitypub {
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpret accept header
|
$accept_header = $_SERVER['HTTP_ACCEPT'];
|
||||||
$pos = \stripos( $_SERVER['HTTP_ACCEPT'], ';' );
|
|
||||||
if ( $pos ) {
|
if (
|
||||||
$accept_header = \substr( $_SERVER['HTTP_ACCEPT'], 0, $pos );
|
stristr( $accept_header, 'application/activity+json' ) ||
|
||||||
} else {
|
stristr( $accept_header, 'application/ld+json' )
|
||||||
$accept_header = $_SERVER['HTTP_ACCEPT'];
|
) {
|
||||||
|
return $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept header as an array
|
// accept header as an array
|
||||||
$accept = \explode( ',', trim( $accept_header ) );
|
$accept = \explode( ',', trim( $accept_header ) );
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
! \in_array( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', $accept, true ) &&
|
||||||
! \in_array( 'application/activity+json', $accept, true ) &&
|
! \in_array( 'application/activity+json', $accept, true ) &&
|
||||||
! \in_array( 'application/ld+json', $accept, true ) &&
|
! \in_array( 'application/ld+json', $accept, true ) &&
|
||||||
! \in_array( 'application/json', $accept, true )
|
! \in_array( 'application/json', $accept, true )
|
||||||
|
|
Loading…
Reference in a new issue