From 3f728f68c7fda85c966aabde70a283e4d0c4c695 Mon Sep 17 00:00:00 2001 From: Shubham Kulkarni Date: Wed, 23 Feb 2022 15:38:52 +0530 Subject: [PATCH] examples/esp_http_client: Use dl.espressif.com URL for performing request with Range header esp_http_client_test.py: Add check for range request log --- .../esp_http_client/esp_http_client_test.py | 6 ++++ .../esp_http_client/main/CMakeLists.txt | 3 +- .../esp_http_client/main/component.mk | 2 +- .../main/dl_espressif_com_root_cert.pem | 29 +++++++++++++++++++ .../main/esp_http_client_example.c | 6 +++- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 examples/protocols/esp_http_client/main/dl_espressif_com_root_cert.pem diff --git a/examples/protocols/esp_http_client/esp_http_client_test.py b/examples/protocols/esp_http_client/esp_http_client_test.py index 17a6d8346c..fe0a54563f 100644 --- a/examples/protocols/esp_http_client/esp_http_client_test.py +++ b/examples/protocols/esp_http_client/esp_http_client_test.py @@ -34,6 +34,9 @@ def test_examples_protocol_esp_http_client(env, extra_data): # content-len for chunked encoding is typically -1, could be a positive length in some cases dut1.expect(re.compile(r'HTTP Stream reader Status = 200, content_length = (\d)')) dut1.expect(re.compile(r'Last esp error code: 0x8001')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = (\d)')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = 10')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = 10')) dut1.expect('Finish http example') # test mbedtls dynamic resource @@ -60,6 +63,9 @@ def test_examples_protocol_esp_http_client(env, extra_data): # content-len for chunked encoding is typically -1, could be a positive length in some cases dut1.expect(re.compile(r'HTTP Stream reader Status = 200, content_length = (\d)')) dut1.expect(re.compile(r'Last esp error code: 0x8001')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = (\d)')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = 10')) + dut1.expect(re.compile(r'HTTP Status = 206, content_length = 10')) dut1.expect('Finish http example') diff --git a/examples/protocols/esp_http_client/main/CMakeLists.txt b/examples/protocols/esp_http_client/main/CMakeLists.txt index 2cb6a74b8a..d4f2d0ce06 100644 --- a/examples/protocols/esp_http_client/main/CMakeLists.txt +++ b/examples/protocols/esp_http_client/main/CMakeLists.txt @@ -3,4 +3,5 @@ # (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.) idf_component_register(SRCS "esp_http_client_example.c" INCLUDE_DIRS "." - EMBED_TXTFILES howsmyssl_com_root_cert.pem) + EMBED_TXTFILES howsmyssl_com_root_cert.pem + dl_espressif_com_root_cert.pem) diff --git a/examples/protocols/esp_http_client/main/component.mk b/examples/protocols/esp_http_client/main/component.mk index cb97ca08ee..ec82632f92 100644 --- a/examples/protocols/esp_http_client/main/component.mk +++ b/examples/protocols/esp_http_client/main/component.mk @@ -5,4 +5,4 @@ # embed files from the "certs" directory as binary data symbols # in the app -COMPONENT_EMBED_TXTFILES := howsmyssl_com_root_cert.pem +COMPONENT_EMBED_TXTFILES := howsmyssl_com_root_cert.pem dl_espressif_com_root_cert.pem diff --git a/examples/protocols/esp_http_client/main/dl_espressif_com_root_cert.pem b/examples/protocols/esp_http_client/main/dl_espressif_com_root_cert.pem new file mode 100644 index 0000000000..42841598fc --- /dev/null +++ b/examples/protocols/esp_http_client/main/dl_espressif_com_root_cert.pem @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIE6jCCA9KgAwIBAgIQCjUI1VwpKwF9+K1lwA/35DANBgkqhkiG9w0BAQsFADBh +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD +QTAeFw0yMDA5MjQwMDAwMDBaFw0zMDA5MjMyMzU5NTlaME8xCzAJBgNVBAYTAlVT +MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxKTAnBgNVBAMTIERpZ2lDZXJ0IFRMUyBS +U0EgU0hBMjU2IDIwMjAgQ0ExMIIBIj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cnfjK+URSxGKqNj +OSD5nkoklEHIqdninFQFBstcHL4AGw+oWv8Zu2XHFq8hVt1hBcnpj5h232sb0HIM +ULkwKXq/YFkQZhM6LawVEWwtIwwCPgU7/uWhnOKK24fXSuhe50gG66sSmvKvhMNb +g0qZgYOrAKHKCjxMoiWJKiKnpPMzTFuMLhoClw+dj20tlQj7T9rxkTgl4ZxuYRiH +as6xuwAwapu3r9rxxZf+ingkquqTgLozZXq8oXfpf2kUCwA/d5KxTVtzhwoT0JzI +8ks5T1KESaZMkE4f97Q= +-----END CERTIFICATE----- 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 d3207260c7..3a8d0bfe9b 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 @@ -38,6 +38,9 @@ static const char *TAG = "HTTP_CLIENT"; extern const char howsmyssl_com_root_cert_pem_start[] asm("_binary_howsmyssl_com_root_cert_pem_start"); extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com_root_cert_pem_end"); +extern const char dl_espressif_com_root_cert_pem_start[] asm("_binary_dl_espressif_com_root_cert_pem_start"); +extern const char dl_espressif_com_root_cert_pem_end[] asm("_binary_dl_espressif_com_root_cert_pem_end"); + esp_err_t _http_event_handler(esp_http_client_event_t *evt) { static char *output_buffer; // Buffer to store response of http request from event handler @@ -632,8 +635,9 @@ static void http_native_request(void) static void http_partial_download(void) { esp_http_client_config_t config = { - .url = "http://jigsaw.w3.org/HTTP/TE/foo.txt", + .url = "https://dl.espressif.com/dl/esp-idf/ci/esp_http_client_demo.txt", .event_handler = _http_event_handler, + .cert_pem = dl_espressif_com_root_cert_pem_start, }; esp_http_client_handle_t client = esp_http_client_init(&config);