httpd: serving gzip index.html

jcsbanks
Posts: 300
Joined: Tue Mar 28, 2017 8:03 pm

httpd: serving gzip index.html

Postby jcsbanks » Thu Mar 05, 2020 8:34 pm

I have an index.html that has grown to 88KB but will gzip to 23KB.

ESP-IDF 3.3 release.

If there anything I can do without digging into and modifying the httpd source code to signal that the file being served is gzipped?

Code: Select all

esp_err_t index_html_get_handler(httpd_req_t *req)
{
    httpd_resp_send(req, (const char*)index_html_start, (index_html_end - index_html_start));
    return ESP_OK;
}

boarchuz
Posts: 236
Joined: Tue Aug 21, 2018 5:28 am

Re: httpd: serving gzip index.html

Postby boarchuz » Thu Mar 05, 2020 10:09 pm

Code: Select all

httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
You may need to set Content Type too, eg:

Code: Select all

httpd_resp_set_type(req, "text/html");

jcsbanks
Posts: 300
Joined: Tue Mar 28, 2017 8:03 pm

Re: httpd: serving gzip index.html

Postby jcsbanks » Thu Mar 05, 2020 11:14 pm

Thanks!

Who is online

Users browsing this forum: Bing [Bot] and 14 guests