Skip to content

Commit

Permalink
Fix response header check to determine whether it is a JSON response.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Jul 26, 2024
1 parent 7bee5eb commit 7850f62
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/HTTP/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ public function request_multiple( array $requests ): array {
* @return Response The response object.
*/
private function create_response( int $status, string $body, array $headers ): Response {
if ( isset( $headers['content-type'] ) && 'application/json' === $headers['content-type'] ) {
if (
isset( $headers['content-type'] ) && (
'application/json' === $headers['content-type'] ||
str_starts_with( $headers['content-type'], 'application/json;' ) ||
str_starts_with( $headers['content-type'], 'application/json,' )
)
) {
return new JSON_Response( $status, $body, $headers );
}

Expand Down

0 comments on commit 7850f62

Please sign in to comment.