The Arduino WiFiClientSecure allocates 16KB TLS buffers by default,
which exhausts the ESP32-C3's limited heap (~46KB free after WiFi)
during the TLS handshake. This causes KOReader sync to fail silently
or crash on HTTPS servers (including the default sync.koreader.rocks).
Replace WiFiClientSecure/HTTPClient with esp_http_client (ESP-IDF),
which supports configurable buffer sizes. Use 2KB TLS buffers — more
than sufficient for KOSync's tiny JSON payloads (<1KB).
Also:
- Use esp_crt_bundle for proper TLS certificate verification instead
of setInsecure()
- Strip trailing slashes from server URL to prevent double-slash in
API paths
- Add lastHttpCode for diagnostics
- Add heap logging to help debug memory issues
Fixes#581
(cherry picked from commit 835abc19ff14fcbea8571ccb0dfd8d21e882b84c)