mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_http_client): Add test case in esp_http_client example
Add a test case in esp_http_client example to test HTTP_METHOD_HEAD with async mode
This commit is contained in:
parent
14a9e01931
commit
102fe3a522
@ -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)
|
||||
|
@ -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)')
|
||||
|
Loading…
x
Reference in New Issue
Block a user