Skip to content

Handle chunked encoding#72

Open
halkeye wants to merge 1 commit intolanrat:mainfrom
halkeye:handle-chunked
Open

Handle chunked encoding#72
halkeye wants to merge 1 commit intolanrat:mainfrom
halkeye:handle-chunked

Conversation

@halkeye
Copy link
Copy Markdown

@halkeye halkeye commented Mar 19, 2026

fixes #71 / #70

Use StreamUtils library to handle http chucked encoding responses.


if (httpCode != HTTP_CODE_OK) {
Serial.printf("[NET] Non-200 response: %d from URL %s\n", httpCode, url);
Serial.printf("[NET] HTTP response buffer: \n\n%s\n\n", http.getString());
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it earlier to do less memory management. getString() handles chunked, and errors probably shoudn't hopefully maybe be binary

@halkeye
Copy link
Copy Markdown
Author

halkeye commented Mar 19, 2026

works for me on my inkplate6v2

@lanrat
Copy link
Copy Markdown
Owner

lanrat commented Mar 28, 2026

Thanks for working on this! The chunked encoding issue is real and needs fixing.

However, I think we can solve this without adding an external library. The ESP32 HTTPClient already has full chunked transfer encoding support built in — the issue is that httpGet() reads from http.getStreamPtr() (raw WiFiClient*), which bypasses the library's decoding. The built-in writeToStream() method handles both chunked and identity encoding transparently — it's the same code path getString() uses internally.

The fix would be to write a small BufferStream shim (~25 lines) that wraps the existing ps_malloc buffer with the Stream interface, then replace the manual read loop with http.writeToStream(&bs). This avoids adding a new dependency, saves flash on an already-constrained ESP32, and requires less code overall.

Note: I did use a LLM to help me research writeToStream(). If the above is incorrect, you may push back. I have a strong preference for not adding additional libraries when not needed for embedded projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trouble reading trmnl json

2 participants