01 Overview
Demonstrates ESP32 as an HTTP client: sending requests, parsing status codes, and reading response bodies.
Ideal for REST API integration, firmware version checks, and simple sensor data reporting.
Not suitable for real-time push from server; use MQTT or WebSocket instead.
Supports both HTTP and HTTPS, but HTTPS requires more resources—plan flash and RAM accordingly.
Built on the esp_http_client component, offering both synchronous and asynchronous modes.
03 Software flow
1. Initialize NVS, Wi-Fi, and wait for GOT_IP event.
2. Create HTTP client instance, configure URL, method, timeout, and certificates.
3. Set request headers (e.g., Content-Type) and body for POST.
4. Perform request; handle response headers and data in event handler.
5. Parse status code and body; distinguish DNS, TLS, and HTTP errors.
6. For HTTPS, use esp_crt_bundle or custom certs; update periodically.
7. Implement retry with exponential backoff to avoid server overload.
8. Run requests in a separate task to avoid blocking the main loop.