refactor(network): Stream parse JSON response from GitHub

While working on enabling OTA for beta updates I kept running into memory issues with the JSON from GitHub. This improves the situation even for the stable OTA releases so I'm putting it up on its own.
This commit is contained in:
Joel Goguen
2026-04-28 20:20:48 -04:00
parent 93f5bdb492
commit af58db7314
3 changed files with 139 additions and 58 deletions
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include <Stream.h>
#include <esp_http_client.h>
#include <cstddef>
#include <cstdint>
class HttpClientStream final : public Stream {
public:
explicit HttpClientStream(esp_http_client_handle_t client, int64_t contentLength);
int available() override;
int read() override;
int peek() override;
size_t write(uint8_t) override;
size_t readBytes(char* buffer, size_t length) override;
size_t bytesReadCount() const { return bytesRead; }
bool hasError() const { return lastReadError < 0; }
int lastError() const { return lastReadError; }
private:
esp_http_client_handle_t client;
int64_t contentLength;
size_t bytesRead = 0;
int lastReadError = 0;
bool endOfStream = false;
};