Skip to content

Commit f914853

Browse files
committed
more flash reduction by gzip html content
1 parent fc62286 commit f914853

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ESPAsyncHTTPUpdateServer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
#define Log(...)
2727
#endif
2828

29-
static const char serverIndex[] PROGMEM =
30-
R"(<!doctypehtml><html lang=en><meta charset=utf-8><meta content="width=device-width,initial-scale=1"name=viewport><form action="?name=firmware"enctype=multipart/form-data method=POST>Firmware:<br><input type=file accept=.bin,.bin.gz name=firmware> <input type=submit value="Update Firmware"></form><form action="?name=filesystem"enctype=multipart/form-data method=POST>FileSystem:<br><input type=file accept=.bin,.bin.gz name=filesystem> <input type=submit value="Update FileSystem"></form>)";
29+
//https://gchq.github.io/CyberChef/#recipe=Gzip('Dynamic%20Huffman%20Coding','','',false)To_Decimal('Comma',false)&input=PCFkb2N0eXBlaHRtbD48aHRtbCBsYW5nPWVuPjxtZXRhIGNoYXJzZXQ9dXRmLTg%2BPG1ldGEgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLGluaXRpYWwtc2NhbGU9MSJuYW1lPXZpZXdwb3J0Pjxmb3JtIGFjdGlvbj0iP25hbWU9ZmlybXdhcmUiZW5jdHlwZT1tdWx0aXBhcnQvZm9ybS1kYXRhIG1ldGhvZD1QT1NUPkZpcm13YXJlOjxicj48aW5wdXQgdHlwZT1maWxlIGFjY2VwdD0uYmluLC5iaW4uZ3ogbmFtZT1maXJtd2FyZT4gPGlucHV0IHR5cGU9c3VibWl0IHZhbHVlPSJVcGRhdGUgRmlybXdhcmUiPjwvZm9ybT48Zm9ybSBhY3Rpb249Ij9uYW1lPWZpbGVzeXN0ZW0iZW5jdHlwZT1tdWx0aXBhcnQvZm9ybS1kYXRhIG1ldGhvZD1QT1NUPkZpbGVTeXN0ZW06PGJyPjxpbnB1dCB0eXBlPWZpbGUgYWNjZXB0PS5iaW4sLmJpbi5neiBuYW1lPWZpbGVzeXN0ZW0%2BIDxpbnB1dCB0eXBlPXN1Ym1pdCB2YWx1ZT0iVXBkYXRlIEZpbGVTeXN0ZW0iPjwvZm9ybT4&oeol=FF
30+
static const uint8_t serverIndex[] PROGMEM =
31+
{31,139,8,0,47,63,148,102,0,255,149,142,77,75,196,48,16,64,255,74,204,121,187,226,77,36,19,111,94,21,86,127,192,52,157,110,7,242,69,58,109,89,127,253,182,193,138,30,4,247,50,144,73,94,222,51,119,93,114,114,201,52,72,240,214,108,83,121,140,103,160,104,77,32,65,229,6,44,35,9,76,210,55,143,251,46,69,161,40,160,23,238,100,128,142,102,118,212,212,195,129,35,11,163,111,70,135,158,224,65,71,12,4,51,211,146,83,17,107,250,84,130,66,39,156,34,232,231,122,217,115,9,11,22,210,20,107,10,132,201,11,103,44,114,191,189,110,58,92,149,171,119,72,29,188,189,158,222,237,203,23,240,100,218,98,13,199,60,137,170,96,207,158,214,207,29,101,129,99,203,241,176,141,227,249,83,253,242,88,245,147,25,167,54,176,168,25,253,68,160,63,242,106,35,181,27,180,53,181,225,143,110,79,227,101,20,10,55,148,123,58,85,228,230,246,221,245,175,250,221,242,221,127,5,2,22,24,226,232,1,0,0};
3132
static const char successResponse[] PROGMEM =
3233
R"(<meta content="15;URL=/"http-equiv=refresh>Update Success! Rebooting...)";
3334

@@ -51,8 +52,9 @@ void ESPAsyncHTTPUpdateServer::setup(AsyncWebServer *server, const String &path,
5152
if(_username != emptyString && _password != emptyString)
5253
if( !request->authenticate(_username.c_str(), _password.c_str()))
5354
return request->requestAuthentication();
54-
55-
request->send_P(200, "text/html", serverIndex); });
55+
AsyncWebServerResponse* response = request->beginResponse_P(200, "text/html", serverIndex, sizeof(serverIndex));
56+
response->addHeader("Content-Encoding", "gzip");
57+
request->send(response); });
5658

5759
// handler for the /update form page - preflight options
5860
_server->on(path.c_str(), HTTP_OPTIONS, [&](AsyncWebServerRequest *request)

0 commit comments

Comments
 (0)