diff --git a/examples/protocols/esp_http_client/main/esp_http_client_example.c b/examples/protocols/esp_http_client/main/esp_http_client_example.c index b0bafef2e0..07b70feedc 100644 --- a/examples/protocols/esp_http_client/main/esp_http_client_example.c +++ b/examples/protocols/esp_http_client/main/esp_http_client_example.c @@ -651,6 +651,31 @@ static void https_async(void) ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); } esp_http_client_cleanup(client); + + // Test HTTP_METHOD_HEAD with is_async enabled + config.url = "https://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get"; + config.event_handler = _http_event_handler; + config.crt_bundle_attach = esp_crt_bundle_attach; + config.is_async = true; + config.timeout_ms = 5000; + + client = esp_http_client_init(&config); + esp_http_client_set_method(client, HTTP_METHOD_HEAD); + + while (1) { + err = esp_http_client_perform(client); + if (err != ESP_ERR_HTTP_EAGAIN) { + break; + } + } + if (err == ESP_OK) { + ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %"PRId64, + esp_http_client_get_status_code(client), + esp_http_client_get_content_length(client)); + } else { + ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err)); + } + esp_http_client_cleanup(client); } static void https_with_invalid_url(void) diff --git a/examples/protocols/esp_http_client/pytest_esp_http_client.py b/examples/protocols/esp_http_client/pytest_esp_http_client.py index 853d7f8a4e..dc22927201 100644 --- a/examples/protocols/esp_http_client/pytest_esp_http_client.py +++ b/examples/protocols/esp_http_client/pytest_esp_http_client.py @@ -46,6 +46,7 @@ def test_examples_protocol_esp_http_client(dut: Dut) -> None: # content-len for chunked encoding is typically -1, could be a positive length in some cases dut.expect(r'HTTP Stream reader Status = 200, content_length = (\d)') dut.expect(r'HTTPS Status = 200, content_length = (\d)') + dut.expect(r'HTTPS Status = 200, content_length = (\d)') dut.expect(r'Last esp error code: 0x8001') dut.expect(r'HTTP GET Status = 200, content_length = (\d)') dut.expect(r'HTTP POST Status = 200, content_length = (\d)') @@ -92,6 +93,7 @@ def test_examples_protocol_esp_http_client_dynamic_buffer(dut: Dut) -> None: # content-len for chunked encoding is typically -1, could be a positive length in some cases dut.expect(r'HTTP Stream reader Status = 200, content_length = (\d)') dut.expect(r'HTTPS Status = 200, content_length = (\d)') + dut.expect(r'HTTPS Status = 200, content_length = (\d)') dut.expect(r'Last esp error code: 0x8001') dut.expect(r'HTTP GET Status = 200, content_length = (\d)') dut.expect(r'HTTP POST Status = 200, content_length = (\d)')