1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

various minor web fixes (#8885)

* httpclient: use refs - httpserver: add chunks in examples

* basic https client: update cert

* debug log: read() returning -1 is usual and means "nothing to read"

* emulation on host: SSL server has never been and is now working

* style

* move SSL server certs from examples into a single place with appropriate warnings

* web-hello-servers: make chunks bigger

* factorize template declaration

* http-client: add getString(pre-reservation)

* mock: add umm_info()

* style

* comment API in example

* style

* fix per review
This commit is contained in:
david gauchard
2023-03-30 19:39:35 +02:00
committed by GitHub
parent d3c102e717
commit 97018a5bbf
18 changed files with 251 additions and 298 deletions

View File

@ -13,6 +13,8 @@ const char* password = STAPSK;
ESP8266WebServer server(80);
String bigChunk;
const int led = 13;
void handleRoot() {
@ -36,6 +38,16 @@ void handleNotFound() {
digitalWrite(led, 0);
}
void handleChunked() {
server.chunkedResponseModeStart(200, F("text/html"));
server.sendContent(bigChunk);
server.sendContent(F("chunk 2"));
server.sendContent(bigChunk);
server.chunkedResponseFinalize();
}
void setup(void) {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
@ -80,6 +92,8 @@ void setup(void) {
server.send(200, "image/gif", gif_colored, sizeof(gif_colored));
});
server.on("/chunks", handleChunked);
server.onNotFound(handleNotFound);
/////////////////////////////////////////////////////////
@ -142,6 +156,15 @@ void setup(void) {
// Hook examples
/////////////////////////////////////////////////////////
// prepare chunk in ram for sending
constexpr int chunkLen = 4000; // ~4KB chunk
bigChunk.reserve(chunkLen);
bigChunk = F("chunk of len ");
bigChunk += chunkLen;
String piece = F("-blah");
while (bigChunk.length() < chunkLen - piece.length())
bigChunk += piece;
server.begin();
Serial.println("HTTP server started");
}