Hello,

I have created a content type quiz where I want the content to be unpublished, promote should stand for publishing or signal whether it is allowed to be included or not.

I wrote a module that fetches the data and displays it as json. The response header is set to 'Access-Control-Allow-Origin', '*'.

In principle, this also works.
Retrieving via the URL (json):
- if promote is set it will be displayed and if promote is not set it will not be displayed (that's right and ok)
- (if promote is set) data is shown if it is published or not published (that's right and ok)

but now it's like this (embed quiz):
- once the content is published, the data is retrieved and the quiz is displayed
- if the content is not published, the data will not be retrieved and the quiz will not be displayed

I noticed that in the header for published a "TE: trailers" is transmitted and not for unpublished and here I think that's the problem.

If I let all the data of the content type be passed to me, "TE: trailers" is appended. However, when I filter for an ID and it is unpublished, "TE: trailers" is not appended.

How can I change this?

- DB query I do with: "\Drupal::entityQuery"
- response I use "Symfony\Component\HttpFoundation\Response"
- I retrieve data with file_get_contents($url)

Comments

HeavyStoneHead created an issue. See original summary.

heavystonehead’s picture

Issue summary: View changes
cilefen’s picture

Status: Active » Postponed

Hello. I’ve read your post but I do not understand what you are asking.

Please share the relevant custom code here to get support. Also please be aware there are better places to get support than in the Drupal Core issue queue.

heavystonehead’s picture

StatusFileSize
new124.37 KB

I wanted to simplify it so that you don't have to go through the confusion of code, but apparently I didn't express myself well.

I had now created an extra module to show it in a simplified way, but funnily enough the effect isn't there and to be honest I don't know how to reproduce it.

at first I thought it could be the cache because I use caching. Then to token filter, but I don't have the effect there.

I have the problem that I can't get any data with "file_get_contents" because the HTML header might be missing "TE: trailers". Funnily enough, it's always there in my test module, whether it's unpublished or published.

I thought at first it was left out on purpose and figured there was a way to add the "TE: trailers".

In order to possibly avoid the eternal search now, the question again very briefly

is it possible to set a "TE: trailers" flag? And if so, how (e.g. with response)

heavystonehead’s picture

StatusFileSize
new99.53 KB
cilefen’s picture

Why are you using file_get_contents instead of Drupal’s HTTP client?

heavystonehead’s picture

if you can regulate it with it, I will use it, I don't know/didn't know that before.

I had just made a new DB query where I set the status to 0, so he attached the TE again. But I will look at that with HTTP and replace it. I also noticed that it loads unreliably, maybe I don't have the problem with loading with the one you described.

thank you very much for your effort.

cilefen’s picture

Status: Postponed » Closed (outdated)

I am closing this as there have been no replies. Reopen it if needed.