Open MarcelBooms opened 6 years ago
I am seeing the same problem of a blank page across several devices and browsers. Win10, both Edge and IE. Android Tablet with Chrome.
Using the sample CaptivePortalAdvanced demonstrates the problem.
Adding to that sample the line you suggest does seem to make it work for the example also.
the chunking code in ESP8266WebServer is broken, and unnecessary.
it's broken, because it doesn't send the terminating chunk correctly unless explicitly told to do so by the user (as illustrated above).
but it's also completely unnecessary to do chunking in the first place:
the code in ESP8266WebServer, below, always sends Connection: close
to the browser. If you send that header, then both the Content-Length
header and chunking are unnecessary - the browser can/will determine the content length from the length of the stream. the only reason to send the Content-Length
header, or use chunking, is if you want to keep the connection open and send another response.
i recommend commenting out the whole chunking initialization section:
/*
//let's do chunked
_chunked = true;
sendHeader(String(F("Accept-Ranges")),String(F("none")));
sendHeader(String(F("Transfer-Encoding")),String(F("chunked")));
*/
Basic Infos
Platform
Settings in IDE
Problem Description
Latest version Chrome browser doesn't display the CaptivePortal webpage when Windows connects to the ESP_ap access point. Instead an empty white page is displayed. The Chrome network tab shows a net::ERR_INCOMPLETE_CHUNKED_ENCODING error. However the page is correctly displayed by Firefox, Edge and Internet Explorer.
An Iphone with latest IOS throws error "Hotspot login cannot open the page because the network connection was lost" when connecting to ESP_ap access point.
server.setContentLength(CONTENT_LENGTH_UNKNOWN); set header "Transfer-Encoding: chunked".
Data is sent in a series of chunks. The Content-Length header is omitted in this case and at the beginning of each chunk you need to add the length of the current chunk in hexadecimal format, followed by '\r\n' and then the chunk itself, followed by another '\r\n'. The terminating chunk is a regular chunk, with the exception that its length is zero.
The terminating chunk is not sent by handleRoot and handWifi function. A server.sendContent(""); before server.client().stop(); solves the issue. A terminating chunk is sent and accepted by the IOS Captive Portal handler and by the Chrome browser.
Sketch handleHttp.ino