Merge branch 'bugfix/esp_http_client_example_v4.3' into 'release/v4.3'

esp_http_client example: Add cert for redirect to HTTPS example (v4.3)

See merge request espressif/esp-idf!18403
This commit is contained in:
Mahavir Jain 2022-06-09 12:35:48 +08:00
commit 49bfb8491f
2 changed files with 27 additions and 0 deletions

View File

@ -25,15 +25,28 @@ def test_examples_protocol_esp_http_client(env, extra_data):
dut1.expect(re.compile(r'HTTP PATCH Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP DELETE Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP HEAD Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP GET Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP POST Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP PUT Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP PATCH Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP DELETE Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP HEAD Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Basic Auth Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Basic Auth redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Digest Auth Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Relative path redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Absolute path redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Absolute path redirect \(manual\) Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP redirect to HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP chunk encoding Status = 200, content_length = (-?\d)'))
# 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'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'Last esp error code: 0x8001'))
dut1.expect(re.compile(r'HTTP GET Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP POST Status = 200, content_length = (\d)'))
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'))
@ -54,15 +67,28 @@ def test_examples_protocol_esp_http_client(env, extra_data):
dut1.expect(re.compile(r'HTTP PATCH Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP DELETE Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP HEAD Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP GET Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP POST Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP PUT Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP PATCH Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP DELETE Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP HEAD Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Basic Auth Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Basic Auth redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Digest Auth Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Relative path redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Absolute path redirect Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP Absolute path redirect \(manual\) Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP redirect to HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP chunk encoding Status = 200, content_length = (-?\d)'))
# 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'HTTPS Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'Last esp error code: 0x8001'))
dut1.expect(re.compile(r'HTTP GET Status = 200, content_length = (\d)'))
dut1.expect(re.compile(r'HTTP POST Status = 200, content_length = (\d)'))
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'))

View File

@ -448,6 +448,7 @@ static void http_redirect_to_https(void)
esp_http_client_config_t config = {
.url = "http://httpbin.org/redirect-to?url=https%3A%2F%2Fwww.howsmyssl.com",
.event_handler = _http_event_handler,
.cert_pem = howsmyssl_com_root_cert_pem_start,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);