Skip to content

Commit

Permalink
Merge pull request #46 from Hieromon/enhance/v156
Browse files Browse the repository at this point in the history
Enhance/v156
  • Loading branch information
Hieromon authored Feb 1, 2023
2 parents 6193e09 + dab018b commit 7c071ad
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: Compile all examples
uses: arduino/compile-sketches@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.platforms }}
enable-deltas-report: true
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![GitHub release](https://img.shields.io/github/v/release/Hieromon/PageBuilder)](https://github.com/Hieromon/PageBuilder/releases)
[![Build Status](https://github.com/Hieromon/PageBuilder/actions/workflows/build.yml/badge.svg)](https://github.com/Hieromon/PageBuilder/actions/workflows/build.yml)
[![arduino-library-badge](https://www.ardu-badge.com/badge/PageBuilder.svg?)](https://www.ardu-badge.com/PageBuilder)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/hieromon/library/PageBuilder.svg?version=1.5.5)](https://registry.platformio.org/packages/libraries/hieromon/PageBuilder?version=1.5.5)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/hieromon/library/PageBuilder.svg?version=1.5.6)](https://registry.platformio.org/packages/libraries/hieromon/PageBuilder?version=1.5.6)
[![License](https://img.shields.io/github/license/Hieromon/PageBuilder)](https://github.com/Hieromon/PageBuilder/blob/master/LICENSE)

*An arduino library to create html string in the sketch for ESP8266/ESP32 WebServer.*
Expand Down Expand Up @@ -382,6 +382,9 @@ Since PageBuilder 1.4.2, the default file system has changed SPIFFS to LittleFS.

## Change log

#### [1.5.6] 2023-01-30
- In ESP8266 core 3.1.0 or later, the default segment length of the chunked encoding has been reduced from 1270 bytes to 510. This measure is to address the situation where ESP8266 core v3.1.0 or later is prone to running out of memory. The default segment length for chunked encoding is defined by the `PAGEBUILDER_CONTENTBLOCK_SIZE` macro in `PageBuilder.h` header file.

#### [1.5.5] 2023-01-05
- Fixed memory leak on cancel sending response.

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"espressif8266",
"espressif32"
],
"version": "1.5.5",
"version": "1.5.6",
"license": "MIT",
"headers": "PageBuilder.h"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PageBuilder
version=1.5.5
version=1.5.6
author=Hieromon Ikasamo <[email protected]>
maintainer=Hieromon Ikasamo <[email protected]>
sentence=HTML string assembly aid library for ESP8266/ESP32 WebServer.
Expand Down
14 changes: 4 additions & 10 deletions src/PageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* PageElement.
* @file PageBuilder.cpp
* @author [email protected]
* @version 1.5.5
* @date 2023-01-05
* @version 1.5.6
* @date 2023-01-30
* @copyright MIT license.
*/

Expand Down Expand Up @@ -505,14 +505,6 @@ bool PageBuilder::canUpload(PageBuilderUtil::URI_TYPE_SIGNATURE uri) {
return true;
}

/**
* Clear the registered PageElements.
*/
void PageBuilder::clearElements(void) {
_elements.clear();
PageElementVT().swap(_elements);
}

/**
* Calculates the approximate content size,
* not including token replacement.
Expand Down Expand Up @@ -670,6 +662,7 @@ void PageBuilder::_handle(int code, WebServer& server) {
server.sendContent_P(contentBlock.c_str());
(void)(blkSize);
PB_DBG("blk:%u\n", blkSize);
server.client().flush();
}
}
else {
Expand Down Expand Up @@ -703,6 +696,7 @@ void PageBuilder::_handle(int code, WebServer& server) {
bp = cBuffer;
cBufferLen = PAGEBUILDER_CONTENTBLOCK_SIZE;
}
server.client().flush();
blkSize = pe.build(bp, cBufferLen, args);
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/PageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Declaration of PageBuilder class and accompanying PageElement, PageArgument class.
* @file PageBuilder.h
* @author [email protected]
* @version 1.5.4
* @date 2022-12-01
* @version 1.5.6
* @date 2023-01-30
* @copyright MIT license.
*/

Expand Down Expand Up @@ -111,6 +111,12 @@ using WebServer = ESP8266WebServer;
// with chunks.
#ifndef PAGEBUILDER_CONTENTBLOCK_SIZE
#define PAGEBUILDER_CONTENTBLOCK_SIZE 1270
#if defined(ARDUINO_ESP8266_MAJOR) && defined(ARDUINO_ESP8266_MINOR) && defined(ARDUINO_ESP8266_REVISION)
#if ARDUINO_ESP8266_MAJOR >= 3 && ARDUINO_ESP8266_MINOR >= 1 && ARDUINO_ESP8266_REVISION >= 0
#undef PAGEBUILDER_CONTENTBLOCK_SIZE
#define PAGEBUILDER_CONTENTBLOCK_SIZE 510
#endif
#endif
#endif

// Delimiter character to appear the token in the page element
Expand Down Expand Up @@ -331,7 +337,7 @@ class PageBuilder : public RequestHandler {
void cancel(const bool cancelation = true) { _cancel = cancelation; }
virtual bool canHandle(HTTPMethod requestMethod, PageBuilderUtil::URI_TYPE_SIGNATURE requestUri) override;
virtual bool canUpload(PageBuilderUtil::URI_TYPE_SIGNATURE uri) override;
void clearElements(void);
void clearElements(void) { _elements.clear(); }
void enableCORS(const bool CORS) { _cors = CORS; }
void exitCanHandle(PrepareFuncT prepareFunc) { _canHandle = prepareFunc; }
bool handle(WebServer& server, HTTPMethod requestMethod, PageBuilderUtil::URI_TYPE_SIGNATURE requestUri) override;
Expand Down

0 comments on commit 7c071ad

Please sign in to comment.