zfcampus/zf-content-negotiation

Accept headers not satisfied in correct order

Wilt opened this issue · 2 comments

Wilt commented

According to the WC3 Specifictations the Server should try to satisfy accept headers in order. Currently the order of the content-types in the Accept header is not respected.

So when I send a request with an Accept header like this: application/xml, application/json it should first try to return a xml and then a json model. When I do application/json, application/xml it should be the other way around.

With a config like this:

    'zf-content-negotiation' => array(
        'controllers' => array(
            'My\Controller\Resource' => 'XML/HalJson'
        ),
        'selectors' => array(
            'XML/HalJson' => array(
                'My\View\XmlModel' => array(
                    'application/xml'
                ),
                'ZF\ContentNegotiation\JsonModel' => array(
                    'application/json',
                    'application/*+json',
                ),
            )
        )
    )

The order of the Accept content-types seems to not be respected by the server. In both cases the same model is set.

Please report this upstream to https://github.com/zendframework/zend-mvc, as the logic by which Accept matching occurs is in the AcceptableViewModelSelector controller plugin.

Wilt commented

I reported it here