Skip to content

Handle chunked encoding - #72

Closed
halkeye wants to merge 1 commit into
lanrat:mainfrom
halkeye:handle-chunked
Closed

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

Conversation

@halkeye

@halkeye halkeye commented Mar 19, 2026

Copy link
Copy Markdown

fixes #71 / #70

Use StreamUtils library to handle http chucked encoding responses.

Comment thread src/network.cpp

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

halkeye commented Mar 19, 2026

Copy link
Copy Markdown
Author

works for me on my inkplate6v2

@lanrat

lanrat commented Mar 28, 2026

Copy link
Copy Markdown
Owner

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.

@lanrat

lanrat commented Apr 4, 2026

Copy link
Copy Markdown
Owner

v1.1.5 has been pushed with support for chunked encoding.

@lanrat lanrat closed this Apr 4, 2026
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