auraphp/Aura.Web

Content class does not handle charset extensions.

Closed this issue · 4 comments

Aura\Web\Request\Content has a type property directly from $_SERVER['CONTENT_TYPE'].
In my requests however these look like: application/json; charset=utf-8.

The content does not get parsed with the built in decoder, because:
"application/json" != "application/json; charset=utf-8".

    protected $decoders = array(
        'application/json' => 'json_decode',
        'application/x-www-form-urlencoded' => 'parse_str',
    );

Perhaps the content class should split the content type over two properties, type and charset.

May be use Aura.Accept which is split from Aura.Web v2 ?

For my application I can. But currently this looks like a bug.
If I send a PUT request with application/json; charset=utf-8, then use $content->get() it will return the JSON data as a string, while I would expect the decoder to work.

Thanks for the report @Beanow -- let me know if that commit takes care of it for you!

At first glance looks good. I'll let you know when I've updated my application to test it.