Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_calling_cb_func_before_perform' into 'master'
Browse files Browse the repository at this point in the history
esp_https_ota: fix bug where `http_client_init_cb` is called after esp_http_client_perform()

Closes IDFGH-8080

See merge request espressif/esp-idf!19897
  • Loading branch information
mahavirj committed Sep 1, 2022
2 parents 0a31319 + 1c92fea commit bc2334d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/esp_https_ota/src/esp_https_ota.c
Expand Up @@ -254,6 +254,14 @@ esp_err_t esp_https_ota_begin(const esp_https_ota_config_t *ota_config, esp_http
goto failure;
}

if (ota_config->http_client_init_cb) {
err = ota_config->http_client_init_cb(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "http_client_init_cb returned 0x%x", err);
goto http_cleanup;
}
}

if (https_ota_handle->partial_http_download) {
esp_http_client_set_method(https_ota_handle->http_client, HTTP_METHOD_HEAD);
err = esp_http_client_perform(https_ota_handle->http_client);
Expand Down Expand Up @@ -286,14 +294,6 @@ esp_err_t esp_https_ota_begin(const esp_https_ota_config_t *ota_config, esp_http
esp_http_client_set_method(https_ota_handle->http_client, HTTP_METHOD_GET);
}

if (ota_config->http_client_init_cb) {
err = ota_config->http_client_init_cb(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "http_client_init_cb returned 0x%x", err);
goto http_cleanup;
}
}

err = _http_connect(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to establish HTTP connection");
Expand Down

0 comments on commit bc2334d

Please sign in to comment.