mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
A blocking transport read can return zero when no data arrives before timeout. Passing that zero length to http_parser_execute signals EOF while a response is incomplete, puts the parser in HPE_INVALID_EOF_STATE, and causes later response bytes to be discarded. The shortened response can then be treated as successful. Skip parser execution for every zero-length transport read, not only async reads. Also compare the raw esp_transport_read result against raw ERR_TCP_TRANSPORT values so timeout and peer-close failures retain their documented HTTP error classifications. A standalone reproduction built with the unmodified HTTP parser showed the blocking timeout transition to HPE_INVALID_EOF_STATE and loss of the remaining 15 bytes. Skipping the zero-length parser call delivered the full chunk and message-complete callback. Disclosure: this fix was prepared with AI assistance (Claude) and reviewed by me before submission. Constraint: esp_http_client_get_data returns raw transport result values before esp_transport_translate_error. Rejected: Keep the async-only zero-length guard | blocking transport reads also return zero on timeout. Confidence: high Scope-risk: moderate Directive: Do not pass a transient zero-length transport read to the HTTP parser as EOF. Tested: standalone blocking mid-chunk timeout reproduction; source-only duplicate-comment cleanup; git diff --check Not-tested: hardware TLS transport integration Signed-off-by: yi chen <94xhn1@gmail.com>