Merge branch 'bugfix/esp-http-client-fixes' into 'release/v3.2'

Minor Bugfixes in esp_http_client, tcp_transport and simple_ota_example. (backport v3.2)

See merge request idf/esp-idf!4248
This commit is contained in:
Angus Gratton 2019-02-13 07:10:34 +08:00
commit 3660ccac4c
3 changed files with 9 additions and 9 deletions

View file

@ -166,7 +166,7 @@ enum HttpStatus_Code
}; };
static esp_err_t esp_http_client_request_send(esp_http_client_handle_t client); static esp_err_t esp_http_client_request_send(esp_http_client_handle_t client, int write_len);
static esp_err_t esp_http_client_connect(esp_http_client_handle_t client); static esp_err_t esp_http_client_connect(esp_http_client_handle_t client);
static esp_err_t esp_http_client_send_post_data(esp_http_client_handle_t client); static esp_err_t esp_http_client_send_post_data(esp_http_client_handle_t client);
@ -817,7 +817,7 @@ esp_err_t esp_http_client_perform(esp_http_client_handle_t client)
} }
/* falls through */ /* falls through */
case HTTP_STATE_CONNECTED: case HTTP_STATE_CONNECTED:
if ((err = esp_http_client_request_send(client)) != ESP_OK) { if ((err = esp_http_client_request_send(client, client->post_len)) != ESP_OK) {
if (client->is_async && errno == EAGAIN) { if (client->is_async && errno == EAGAIN) {
return ESP_ERR_HTTP_EAGAIN; return ESP_ERR_HTTP_EAGAIN;
} }
@ -997,11 +997,11 @@ static int http_client_prepare_first_line(esp_http_client_handle_t client, int w
return first_line_len; return first_line_len;
} }
static esp_err_t esp_http_client_request_send(esp_http_client_handle_t client) static esp_err_t esp_http_client_request_send(esp_http_client_handle_t client, int write_len)
{ {
int first_line_len = 0; int first_line_len = 0;
if (!client->first_line_prepared) { if (!client->first_line_prepared) {
if ((first_line_len = http_client_prepare_first_line(client, client->post_len)) < 0) { if ((first_line_len = http_client_prepare_first_line(client, write_len)) < 0) {
return first_line_len; return first_line_len;
} }
client->first_line_prepared = true; client->first_line_prepared = true;
@ -1092,7 +1092,7 @@ esp_err_t esp_http_client_open(esp_http_client_handle_t client, int write_len)
if ((err = esp_http_client_connect(client)) != ESP_OK) { if ((err = esp_http_client_connect(client)) != ESP_OK) {
return err; return err;
} }
if ((err = esp_http_client_request_send(client)) != ESP_OK) { if ((err = esp_http_client_request_send(client, write_len)) != ESP_OK) {
return err; return err;
} }
return ESP_OK; return ESP_OK;

View file

@ -110,7 +110,7 @@ static int ssl_write(esp_transport_handle_t t, const char *buffer, int len, int
return poll; return poll;
} }
ret = esp_tls_conn_write(ssl->tls, (const unsigned char *) buffer, len); ret = esp_tls_conn_write(ssl->tls, (const unsigned char *) buffer, len);
if (ret <= 0) { if (ret < 0) {
ESP_LOGE(TAG, "esp_tls_conn_write error, errno=%s", strerror(errno)); ESP_LOGE(TAG, "esp_tls_conn_write error, errno=%s", strerror(errno));
} }
return ret; return ret;
@ -127,7 +127,7 @@ static int ssl_read(esp_transport_handle_t t, char *buffer, int len, int timeout
} }
} }
ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len); ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len);
if (ret <= 0) { if (ret < 0) {
ESP_LOGE(TAG, "esp_tls_conn_read error, errno=%s", strerror(errno)); ESP_LOGE(TAG, "esp_tls_conn_read error, errno=%s", strerror(errno));
} }
return ret; return ret;

View file

@ -1,7 +1,7 @@
# Simple OTA example # Simple OTA example
This example is based on `http_firmware_upgrade` component's APIs. This example is based on `esp_https_ota` component's APIs.
## Configuration ## Configuration
Refer README.md in the parent directory for setup details Refer README.md in the parent directory for setup details