Skip to content

Response Content-Type check is too strict #492

@sabadriwan

Description

@sabadriwan

Description of the problem:

Currently the library checks the response Content-Type too strictly:

if ($this->getResponseContentType() === 'application/jwt') {
    // ...
}

However, some servers return a Content-Type with additional parameters, for example:

Content-Type: application/jwt; charset=utf-8

Proposed Solution

Relax the check so that it accepts Content-Types starting with application/jwt:

if (strpos($this->getResponseContentType(), 'application/jwt') === 0) {
    // ...
}

This will correctly match both application/jwt and application/jwt; charset=utf-8.

See PR : #493

Technical notes

  • We considered using str_contains for readability, but since the library still supports PHP 7, we chose strpos for compatibility.
  • If/when PHP 7 support is dropped, the condition could be updated to str_contains for clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions