ESPHome 2026.2.3
Loading...
Searching...
No Matches
http_request_arduino.h
Go to the documentation of this file.
1#pragma once
2
3#include "http_request.h"
4
5#if defined(USE_ARDUINO) && !defined(USE_ESP32)
6
7#if defined(USE_RP2040)
8#include <HTTPClient.h>
9#include <WiFiClient.h>
10#endif
11#ifdef USE_ESP8266
12#include <ESP8266HTTPClient.h>
13#ifdef USE_HTTP_REQUEST_ESP8266_HTTPS
14#include <WiFiClientSecure.h>
15#endif
16#endif
17
18namespace esphome::http_request {
19
20class HttpRequestArduino;
21
31
33 public:
34 int read(uint8_t *buf, size_t max_len) override;
35 void end() override;
36
37 protected:
38 friend class HttpRequestArduino;
39 HTTPClient client_{};
40
42 int read_chunked_(uint8_t *buf, size_t max_len, WiFiClient *stream);
46 size_t chunk_remaining_{0};
47};
48
50 protected:
51 std::shared_ptr<HttpContainer> perform(const std::string &url, const std::string &method, const std::string &body,
52 const std::list<Header> &request_headers,
53 const std::set<std::string> &collect_headers) override;
54};
55
56} // namespace esphome::http_request
57
58#endif // USE_ARDUINO && !USE_ESP32
int read_chunked_(uint8_t *buf, size_t max_len, WiFiClient *stream)
Decode chunked transfer encoding from the raw stream.
size_t chunk_remaining_
Bytes remaining in current chunk.
int read(uint8_t *buf, size_t max_len) override
void chunk_header_complete_()
Transition from chunk header to data or trailer based on parsed size.
std::shared_ptr< HttpContainer > perform(const std::string &url, const std::string &method, const std::string &body, const std::list< Header > &request_headers, const std::set< std::string > &collect_headers) override
@ COMPLETE
All content has been read, caller should exit loop.
ChunkedState
State machine for decoding chunked transfer encoding on Arduino.
@ CHUNK_DATA
Reading chunk data bytes.
@ CHUNK_HEADER
Reading hex digits of chunk size.
@ CHUNK_HEADER_EXT
Skipping chunk extensions until .
@ CHUNK_DATA_TRAIL
Skipping \r after chunk data.
@ CHUNK_TRAILER
Consuming trailer headers after final 0-size chunk.