khoih-prog / Portenta_H7_AsyncWebServer

Asynchronous WebServer Library for STM32H7-based Portenta_H7 using mbed_portenta core. This library, which is relied on Portenta_H7_AsyncTCP, is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequest, AsyncHTTPSRequest, etc. Now supporting using CString in optional SDRAM to save heap to send very large data
GNU Lesser General Public License v3.0
12 stars 3 forks source link

request->send(200, textPlainStr, jsonChartDataCharStr); - Without using String Class - to save heap #7

Closed khoih-prog closed 2 years ago

khoih-prog commented 2 years ago

This PR is from @salasidis


As per the Readme.md file - I am getting 66k instead of 374k max heap space in my application. I should have no problem sending 2M files, or web pages larger than the main RAM

Since I create the web page once, and reuse, I make a second copy of the web page, so that when the send happens (which messes wit the actual string), I simply recopy C string C string for the next send - fast, easy, and almost no code changes required (none if you don't wish to use the features 0 fully backwards compatible I think)

request->send(200, "text/html", html_out, false);
strcpy(html_out, html_out_bak);
khoih-prog commented 2 years ago

LGTM. You've written very good code.

Can you make some minor changes to match with the current styles

  1. Using AWS_LOGDEBUGx instead of Serial.printxx
  2. Using tab = 2 spaces for correct indentation
  3. Modify in README.md correctly by adding a note how to use the new feature / function

BTW, to create a PR, after you've forked the library and have done all the mods, just press Pull Requests (upper left corner, next to Code, and proceed. Just so simple for you.

khoih-prog commented 2 years ago

Replaced by the real PR #8