You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CaptivePortalAdvanced: Fix compatibility with Android (#5069)
Android refuses to show page with missing Content-Length header.
Prepare page data to String and send it with server.send
Moved respose strings to PROGMEM
server.send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
11
-
server.sendContent(
12
-
"<html><head></head><body>"
13
-
"<h1>HELLO WORLD!!</h1>"
14
-
);
9
+
10
+
String Page;
11
+
Page += F(
12
+
"<html><head></head><body>"
13
+
"<h1>HELLO WORLD!!</h1>");
15
14
if (server.client().localIP() == apIP) {
16
-
server.sendContent(String("<p>You are connected through the soft AP: ") + softAP_ssid + "</p>");
15
+
Page += String(F("<p>You are connected through the soft AP: ")) + softAP_ssid + F("</p>");
17
16
} else {
18
-
server.sendContent(String("<p>You are connected through the wifi network: ") + ssid + "</p>");
17
+
Page += String(F("<p>You are connected through the wifi network: ")) + ssid + F("</p>");
19
18
}
20
-
server.sendContent(
21
-
"<p>You may want to <a href='/wifi'>config the wifi connection</a>.</p>"
22
-
"</body></html>"
23
-
);
24
-
server.client().stop(); // Stop is needed because we sent no content length
19
+
Page += F(
20
+
"<p>You may want to <a href='/wifi'>config the wifi connection</a>.</p>"
21
+
"</body></html>");
22
+
23
+
server.send(200, "text/html", Page);
25
24
}
26
25
27
26
/** Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */
0 commit comments