Page 1 of 1

httpd: serving gzip index.html

Posted: Thu Mar 05, 2020 8:34 pm
by jcsbanks
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;
}

Re: httpd: serving gzip index.html

Posted: Thu Mar 05, 2020 10:09 pm
by boarchuz

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");

Re: httpd: serving gzip index.html

Posted: Thu Mar 05, 2020 11:14 pm
by jcsbanks
Thanks!