Problem/Motivation

  1. Install drupal
  2. Enable RESTful Web Services
  3. Add a rest export display to the front page view admin/structure/views/view/frontpage/edit
  4. Set the path to /node
  5. Check json for "Accepted request formats"
  6. Save the view
  7. Visit frontpage or curl --request GET 'http://drupal.d8/node' even trying to force the response http://drupal.d8/?_format=html fails.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

clemens.tolboom created an issue. See original summary.

dawehner’s picture

Interesting!!

imalabya’s picture

Can you try with the latest drupal-rc2 version. Followed the same steps and it is working fine. The JSON output is being displayed.

clemens.tolboom’s picture

@malavya the frontpage must show HTML not JSON as we are not requesting json ... please recheck

imalabya’s picture

Ahh.. sorry, my bad. Read it other way round. But to get the HTML out I suppose it needs to a HTML formatter in the serializer?

clemens.tolboom’s picture

@malavya just visit the frontpage with your browser :p then you should see HTML not JSON

dawehner’s picture

The problem is the following line of code:

        // Allow a REST Export View to be returned with an HTML-only accept
        // format. That allows browsers or other non-compliant systems to access
        // the view, as it is unlikely to have a conflicting HTML representation
        // anyway.
        $route->setRequirement('_format', implode('|', $formats + ['html']));

As you see, HTML is always added to the allowed formats, as we thought at some point its a good idea to have those sites be accessible via the browser.
Maybe we should better decide that this is a bad idea in the first place ...

clemens.tolboom’s picture

I was puzzled with the _format=html not throwing an exception related to #2594777: Accessing a non existing format results in a 500

Why should I allow non-compliant systems to get my view? I want Drupal to throw an exception so my site bug are not contaminated with html-rest related issues.

So yeah .... let's remove that auto _format if possible. Or make it configurable thus explicit.

dawehner’s picture

So yeah .... let's remove that auto _format if possible. Or make it configurable thus explicit.

Well, I don't have the energy to fight this (probably hopeless) battle with webchick, but feel free to do so.

clemens.tolboom’s picture

Huh ... extra info: webchick was on favor of this obscured auto html?

Do you have some more info or should I just write the simple 'removal' patch then see what happens?

dawehner’s picture