Skip to content

Commit

Permalink
Fix chunked encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Nov 21, 2024
1 parent 8a7c4c1 commit 0d68247
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)

![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.4.8-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.4.9-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Revision `2024-11-19T08:17:19Z`
Revision `2024-11-21T07:02:31Z`

## Table of Contents

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.4.8",
"version": "1.4.9",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.4.8
version=1.4.9

author=Mobizt

Expand Down
12 changes: 9 additions & 3 deletions src/core/AsyncClient/AsyncClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ class AsyncClientClass : public ResultBase, RTDBResultBase
{
if (line.length() == 0)
readLine(sData, line);

int p = line.indexOf(";");
if (p == -1)
p = line.indexOf("\r\n");
Expand Down Expand Up @@ -1079,6 +1080,10 @@ class AsyncClientClass : public ResultBase, RTDBResultBase
// check for \n and \r, remove them if present (they're part of the protocol, not the data)
if (read >= 2 && line[read - 2] == '\r' && line[read - 1] == '\n')
{
// last chunk?
if (line[0] == '0') // last-chunk , chunk-extension (if any) and CRLF
goto next;

// remove the \r\n
line.remove(line.length() - 2);
read -= 2;
Expand All @@ -1103,13 +1108,14 @@ class AsyncClientClass : public ResultBase, RTDBResultBase
}
else
{
// last chunk, read until the final CRLF so the rest of the logic based on available() works

next:
read = readLine(sData, line);

// if we read a CRLF, we're done
// CRLF (end of chunked body)
if (read == 2 && line[0] == '\r' && line[1] == '\n')
res = -1;
else // that could be a last chunk size, continue to read the last chunk-data and CRLF
else // another chunk?
getChunkSize(sData, client, line);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.4.8"
#define FIREBASE_CLIENT_VERSION "1.4.9"

static void sys_idle()
{
Expand Down

0 comments on commit 0d68247

Please sign in to comment.