提交 18b31114 编写于 作者: 云逸之's avatar 云逸之 💬

更新详细使用说明

上级 5a63884e
......@@ -15,18 +15,35 @@ const uint8_t index_html_gz[] = {
用于mcu节省空间
以下使用 `esp_http_server.h`。设置http响应头`Content-Encoding` 中压缩格式,让浏览器按gzip格式解压
设置http响应头`Content-Encoding` 中压缩格式,让浏览器按gzip格式解压
详细使用说明 : https://blog.csdn.net/qq_26700087/article/details/125963998?spm=1001.2014.3001.5502
esp32系列按以下方式
```cpp
#include "esp_http_server.h"
//省略中间
httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
```
或者
```cpp
#include <ESPMDNS.h>
#include <WebServer.h>
#include <WiFi.h>
#include <WiFiClient.h>
WebServer server(80);
// ... 省略中间
server.sendHeader("Content-Encoding", "gzip");
server.send_P(200, "text/html", (const char*)index_html_gz, index_html_len);
```
esp8266按以下方式
```cpp
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiClient.h>
ESP8266WebServer server(80);
// ... 省略中间
server.sendHeader("Content-Encoding", "gzip");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册