Skip to content

Conversation

@JLTRY
Copy link

@JLTRY JLTRY commented Nov 7, 2025

case of header =
Array
(
[0] => application/json; charset=utf-8
)
correct phpstan

Pull Request for Issue #19

Summary of Changes

accept application/json; charset=utf-8 in header

Testing Instructions

checked with extension for Google authentification
https://extensions.joomla.org/extension/access-a-security/jo-s-google-auth/

Documentation Changes Required

no

case of header =
Array
(
    [0] => application/json; charset=utf-8
)
correct phpstan
@JLTRY
Copy link
Author

JLTRY commented Jan 5, 2026

@rdeutz @richard67 @LadySolveig I need this pull request to be able to run correctly my google auth extension
https://extensions.joomla.org/extension/access-a-security/jo-s-google-auth/
PErhaps is it due to french site and google providing an "application/json; charset=utf-8" in response header

@HLeithner
Copy link

Somethings are wrong here.

getHeader() is case insensitive, so the loop is not needed, also strpos is pre php 8.0, use str_starts_with instead.

my suggestion:
change

if (in_array('application/json', $response->getHeader('Content-Type'))) {

to

if (str_starts_with('application/json', strtolower($response->getHeader('Content-Type')[0]))) {

but that's not really correct, you should iterate over the getHeader() result array an check each row, as done in the original if statement.

do not use strpos use str_starts_with instead.
getHeader() is case insensitive
@JLTRY
Copy link
Author

JLTRY commented Jan 8, 2026

@HLeithner I modified the code following your directives
I tested it OK with my component

@JLTRY JLTRY changed the title JSon response not detected JSon response not detected with header containing utf8 Jan 14, 2026
@JLTRY JLTRY requested a review from rdeutz January 14, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants