Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept headers not satisfied in correct order by AcceptableViewModelSelector controller plugin #37

Closed
michalbundyra opened this issue Jan 15, 2020 · 3 comments

Comments

@michalbundyra
Copy link
Member

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.

The AcceptableViewModelSelector controller plugin does not seem to respect the order in which content types are requested.

I reported this issue here inside Apigility module but it turned out the behavior is caused by the Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector controller plugin.


Originally posted by @Wilt at zendframework/zend-mvc#16

@michalbundyra
Copy link
Member Author

Is this still an issue? I tried this test case and it passes:

    public function testZendMvcIssue16()
    {
        $arr = [
            'Zend\View\Model\JsonModel' => ['application/json'],
            'Zend\View\Model\FeedModel' => ['application/rss+xml'],
        ];

        $header   = Accept::fromString('application/rss+xml, application/json');
        $this->request->getHeaders()->addHeader($header);
        $plugin   = $this->plugin;
        $result   = $plugin($arr);

        $this->assertEquals('Zend\View\Model\ViewModel', $this->plugin->getDefaultViewModelName());

        $this->assertInstanceOf('Zend\View\Model\FeedModel', $result);
        $this->assertNotInstanceOf('Zend\View\Model\JsonModel', $result);
    }

Originally posted by @adamlundrigan at zendframework/zend-mvc#16 (comment)

@michalbundyra
Copy link
Member Author

Thanks for checking this.
I am not sure since I haven't tested it for a long time.
I can see if the issue still applies, will get back on this.


Originally posted by @Wilt at zendframework/zend-mvc#16 (comment)

@alexmerlin
Copy link
Member

Closing issue due to being inactive for more than 1 year.

@alexmerlin alexmerlin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants