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

Template processing error with IOS18 #1435

Closed
hakkapet opened this issue Sep 25, 2024 · 5 comments
Closed

Template processing error with IOS18 #1435

hakkapet opened this issue Sep 25, 2024 · 5 comments

Comments

@hakkapet
Copy link

Hi, just noticed that some reason when Iphone is updated to IOS18.
Template processing wont work anymore in Safari browser: It just gives an "cannot parse response" error to Safari. So i this is Safari/IOS18 error, but it would be nice to know why this wont work anymore. It is crucial functionality almost everywhere in web applications. Other browsers (Chrome) what i was trying to use works fine. Some reason return page from AwsTemplateProcessor is interpreted as faulty in Safari.

Example this wont work anymore:

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
        const char * html = "<p>Temperature: %PLACEHOLDER_TEMPERATURE% ºC</p><p>Humidity: %PLACEHOLDER_HUMIDITY% %</p>";
          request->send_P(200, "text/html", html, processor); 
});

or this wont work:

    server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
          request->send(LittleFS, "/index.html", "text/html;", false, processor);
    });

Without processor it gives page without problem.
request->send_p(200, "text/html", html);

Even if processor is so simple that:

String processor(const String& var) {
  return "";
}

@nonnullish
Copy link

I have just run into the exact same issue. I think the problem is that the Content-Type and Content-Length headers are missing when using a processor. As a work-around, I added the Content-Type header, but I'm not sure yet how to calculate the content length there...

AsyncWebServerResponse* response = request->beginResponse(LittleFS, "/index.html", String(), false, processor);
response->addHeader("Content-Type", "text/html; charset=UTF-8");
request->send(response);

@hakkapet
Copy link
Author

I examined response (in Edge, only have iphone so cannot debug) and library adds Content-Type header, even without addHeader. Response Transfer-Encoding is "chunked" so Content-Length is omitted. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding
However i havent yet explored how that lib handles chunked responses. I think it is something to do with that.

@nonnullish
Copy link

Apparently there's a PR open with a fix for this issue: #1301 (linking this discussion for more context).

@hakkapet
Copy link
Author

@nonnullish thanks! i checked that another fork by @mathieucarbou it is much better and works also with IOS18

@mathieucarbou
Copy link

mathieucarbou commented Sep 27, 2024

Yes, we are maintaining it at https://oss.carbou.me/ESPAsyncWebServer/ and it has a lot more features, like middlewares ;-)

And the fix #1301 is already in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants