Skip to content

Commit 845275c

Browse files
committed
fix(esp_http_client): fix dispatching of finish event condition
This commit updates the condition for dispatching of FINISH event. With this, FINISH event will be dispatched after complete data is read. Closes #17437
1 parent e3190c6 commit 845275c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

components/esp_http_client/esp_http_client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,11 +1538,11 @@ esp_err_t esp_http_client_perform(esp_http_client_handle_t client)
15381538
if (err != ESP_OK) {
15391539
http_dispatch_event(client, HTTP_EVENT_ERROR, esp_transport_get_error_handle(client->transport), 0);
15401540
http_dispatch_event_to_event_loop(HTTP_EVENT_ERROR, &client, sizeof(esp_http_client_handle_t));
1541+
} else {
1542+
http_dispatch_event(client, HTTP_EVENT_ON_FINISH, NULL, 0);
1543+
http_dispatch_event_to_event_loop(HTTP_EVENT_ON_FINISH, &client, sizeof(esp_http_client_handle_t));
15411544
}
15421545

1543-
http_dispatch_event(client, HTTP_EVENT_ON_FINISH, NULL, 0);
1544-
http_dispatch_event_to_event_loop(HTTP_EVENT_ON_FINISH, &client, sizeof(esp_http_client_handle_t));
1545-
15461546
client->response->buffer->raw_len = 0;
15471547
if (!http_should_keep_alive(client->parser)) {
15481548
ESP_LOGD(TAG, "Close connection");

components/esp_http_client/include/esp_http_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef enum {
4242
HTTP_EVENT_ON_HEADERS_COMPLETE, /*!< Occurs when all headers are received on the client side */
4343
HTTP_EVENT_ON_STATUS_CODE, /*!< Occurs when receiving the HTTP status code from the server */
4444
HTTP_EVENT_ON_DATA, /*!< Occurs when receiving data from the server, possibly multiple portions of the packet */
45-
HTTP_EVENT_ON_FINISH, /*!< Occurs when finish a HTTP session */
45+
HTTP_EVENT_ON_FINISH, /*!< Occurs when complete data is received */
4646
HTTP_EVENT_DISCONNECTED, /*!< The connection has been disconnected */
4747
HTTP_EVENT_REDIRECT, /*!< Intercepting HTTP redirects to handle them manually */
4848
} esp_http_client_event_id_t;

0 commit comments

Comments
 (0)