Skip to content

Commit c9ff85a

Browse files
Merge pull request #263 from ESP32Async/gz
Update sample to add content served from gz file
2 parents 45114e9 + 7f3e8b3 commit c9ff85a

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

examples/StaticFile/StaticFile.ino

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,30 @@ static const char *htmlContent PROGMEM = R"(
8484

8585
static const size_t htmlContentLength = strlen_P(htmlContent);
8686

87+
// sample_html_gz.h
88+
static const uint8_t index2_html_gz[] = {
89+
0x1f, 0x8b, 0x08, 0x08, 0x13, 0x45, 0x92, 0x68, 0x00, 0x03, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x32, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0xed, 0x98, 0xcb,
90+
0x6e, 0xdc, 0x30, 0x0c, 0x45, 0xf7, 0xf3, 0x15, 0xcc, 0xde, 0xb0, 0x91, 0xbd, 0xe1, 0x4d, 0x1f, 0x48, 0x81, 0xbc, 0x8a, 0x26, 0x2d, 0xba, 0xe4, 0x48,
91+
0x8c, 0x87, 0x81, 0x1e, 0x0e, 0x25, 0x19, 0xc8, 0xdf, 0x97, 0xb2, 0x67, 0x82, 0x6c, 0xfa, 0x07, 0x32, 0x0c, 0x58, 0xa6, 0xa8, 0xcb, 0x4b, 0xe9, 0xac,
92+
0x34, 0x5e, 0x7d, 0x7d, 0xf8, 0xf2, 0xf4, 0xf7, 0xf1, 0x1b, 0x9c, 0xb2, 0x77, 0xd3, 0x61, 0xbc, 0x7c, 0x08, 0xed, 0x74, 0x00, 0x7d, 0xc6, 0xcc, 0xd9,
93+
0xd1, 0xf4, 0x0b, 0xfd, 0xe2, 0x08, 0x6e, 0x9e, 0xee, 0x6e, 0xc7, 0x61, 0x0f, 0x1d, 0xc6, 0x61, 0x4f, 0x1b, 0x8f, 0xd1, 0xbe, 0x9f, 0xb3, 0x4f, 0xd7,
94+
0xd3, 0x0d, 0x39, 0x17, 0x3b, 0xf8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9, 0x9b, 0x1e, 0xee, 0xab, 0x2f, 0x78, 0x41, 0xc3, 0x8e, 0x13, 0xf7, 0x5b,
102+
0x81, 0x1f, 0x21, 0xd3, 0x4c, 0xba, 0xa3, 0xc5, 0x54, 0xe7, 0x9f, 0x37, 0xb9, 0xb8, 0x2c, 0x6c, 0x98, 0x74, 0xe5, 0xf7, 0x92, 0x0c, 0xa9, 0xeb, 0x32,
103+
0x33, 0xea, 0x51, 0x78, 0xfe, 0x38, 0x17, 0x38, 0xf2, 0x91, 0x82, 0xd5, 0xce, 0x56, 0x5e, 0x49, 0x44, 0xb7, 0x31, 0x8a, 0x61, 0x70, 0x14, 0x37, 0x7d,
104+
0x8b, 0x0b, 0x1f, 0xd5, 0x50, 0xed, 0xa8, 0x03, 0xb6, 0x17, 0x83, 0x49, 0xcf, 0xd9, 0x16, 0xae, 0x91, 0xcd, 0x78, 0x3f, 0x0e, 0x4b, 0xc3, 0xa0, 0x61,
105+
0xd0, 0x30, 0x68, 0x18, 0x34, 0x0c, 0x1a, 0x06, 0x0d, 0x83, 0x86, 0x41, 0xc3, 0xa0, 0x61, 0xd0, 0x30, 0x68, 0x18, 0x34, 0x0c, 0x1a, 0x06, 0xff, 0xc1,
106+
0x60, 0x1c, 0xf6, 0xab, 0x85, 0x71, 0xd8, 0xee, 0x25, 0xfe, 0x01, 0xa0, 0xec, 0x78, 0xfe, 0xae, 0x10, 0x00, 0x00
107+
};
108+
109+
static const size_t index2_html_gz_len = sizeof(index2_html_gz);
110+
87111
void setup() {
88112
Serial.begin(115200);
89113

@@ -105,6 +129,13 @@ void setup() {
105129
f.close();
106130
}
107131

132+
{
133+
File f = LittleFS.open("/index2.html.gz", "w");
134+
assert(f);
135+
f.write(index2_html_gz, index2_html_gz_len);
136+
f.close();
137+
}
138+
108139
LittleFS.mkdir("/files");
109140

110141
{
@@ -129,6 +160,9 @@ void setup() {
129160
// curl -v http://192.168.4.1/index.html
130161
server.serveStatic("/index.html", LittleFS, "/index.html");
131162

163+
// curl -v http://192.168.4.1/index2.html | gunzip -c
164+
server.serveStatic("/index2.html", LittleFS, "/index2.html");
165+
132166
// Example to serve a directory content
133167
// curl -v http://192.168.4.1/base/ => serves a.txt
134168
// curl -v http://192.168.4.1/base/a.txt => serves a.txt

0 commit comments

Comments
 (0)