Skip to content

Commit 9d88055

Browse files
committed
feat(esp_http_client): Unable to recognise http requests logs
In the esp_http_client_example, it becomes difficult to determine which request or request type a log belongs to.
1 parent 8014ffa commit 9d88055

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/protocols/esp_http_client/main/esp_http_client_example.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static void http_rest_with_url(void)
160160
.user_data = local_response_buffer, // Pass address of local buffer to get response
161161
.disable_auto_redirect = true,
162162
};
163+
ESP_LOGI(TAG, "HTTP request with url =>");
163164
esp_http_client_handle_t client = esp_http_client_init(&config);
164165

165166
// GET
@@ -248,6 +249,7 @@ static void http_rest_with_hostname_path(void)
248249
.transport_type = HTTP_TRANSPORT_OVER_TCP,
249250
.event_handler = _http_event_handler,
250251
};
252+
ESP_LOGI(TAG, "HTTP request with hostname and path =>");
251253
esp_http_client_handle_t client = esp_http_client_init(&config);
252254

253255
// GET
@@ -342,6 +344,7 @@ static void http_auth_basic(void)
342344
.auth_type = HTTP_AUTH_TYPE_BASIC,
343345
.max_authorization_retries = -1,
344346
};
347+
ESP_LOGI(TAG, "HTTP Basic Auth request =>");
345348
esp_http_client_handle_t client = esp_http_client_init(&config);
346349
esp_err_t err = esp_http_client_perform(client);
347350

@@ -361,6 +364,7 @@ static void http_auth_basic_redirect(void)
361364
.url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/basic-auth/user/passwd",
362365
.event_handler = _http_event_handler,
363366
};
367+
ESP_LOGI(TAG, "HTTP Basic Auth redirect request =>");
364368
esp_http_client_handle_t client = esp_http_client_init(&config);
365369
esp_err_t err = esp_http_client_perform(client);
366370

@@ -382,6 +386,7 @@ static void http_auth_digest_md5(void)
382386
.url = "http://user:passwd@"CONFIG_EXAMPLE_HTTP_ENDPOINT"/digest-auth/auth/user/passwd/MD5/never",
383387
.event_handler = _http_event_handler,
384388
};
389+
ESP_LOGI(TAG, "HTTP MD5 Digest Auth request =>");
385390
esp_http_client_handle_t client = esp_http_client_init(&config);
386391
esp_err_t err = esp_http_client_perform(client);
387392

@@ -402,6 +407,7 @@ static void http_auth_digest_sha256(void)
402407
.event_handler = _http_event_handler,
403408
.buffer_size_tx = 1024, // Increase buffer size as header size will increase as it contains SHA-256.
404409
};
410+
ESP_LOGI(TAG, "HTTP SHA256 Digest Auth request =>");
405411
esp_http_client_handle_t client = esp_http_client_init(&config);
406412
esp_err_t err = esp_http_client_perform(client);
407413

@@ -424,6 +430,7 @@ static void https_with_url(void)
424430
.event_handler = _http_event_handler,
425431
.crt_bundle_attach = esp_crt_bundle_attach,
426432
};
433+
ESP_LOGI(TAG, "HTTPS request with url =>");
427434
esp_http_client_handle_t client = esp_http_client_init(&config);
428435
esp_err_t err = esp_http_client_perform(client);
429436

@@ -447,6 +454,7 @@ static void https_with_hostname_path(void)
447454
.event_handler = _http_event_handler,
448455
.cert_pem = howsmyssl_com_root_cert_pem_start,
449456
};
457+
ESP_LOGI(TAG, "HTTPS request with hostname and path =>");
450458
esp_http_client_handle_t client = esp_http_client_init(&config);
451459
esp_err_t err = esp_http_client_perform(client);
452460

@@ -467,6 +475,7 @@ static void http_encoded_query(void)
467475
.path = "/get",
468476
.event_handler = _http_event_handler,
469477
};
478+
ESP_LOGI(TAG, "HTTP GET request with encoded query =>");
470479

471480
static const char query_val[] = "ABC xyz!012@#%&";
472481
char query_val_enc[64] = {0};
@@ -494,6 +503,7 @@ static void http_relative_redirect(void)
494503
.url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/relative-redirect/3",
495504
.event_handler = _http_event_handler,
496505
};
506+
ESP_LOGI(TAG, "HTTP Relative path redirect request =>");
497507
esp_http_client_handle_t client = esp_http_client_init(&config);
498508
esp_err_t err = esp_http_client_perform(client);
499509

@@ -513,6 +523,7 @@ static void http_absolute_redirect(void)
513523
.url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/absolute-redirect/3",
514524
.event_handler = _http_event_handler,
515525
};
526+
ESP_LOGI(TAG, "HTTP Absolute path redirect request =>");
516527
esp_http_client_handle_t client = esp_http_client_init(&config);
517528
esp_err_t err = esp_http_client_perform(client);
518529

@@ -533,6 +544,7 @@ static void http_absolute_redirect_manual(void)
533544
.event_handler = _http_event_handler,
534545
.disable_auto_redirect = true,
535546
};
547+
ESP_LOGI(TAG, "HTTP Absolute path redirect (manual) request =>");
536548
esp_http_client_handle_t client = esp_http_client_init(&config);
537549
esp_err_t err = esp_http_client_perform(client);
538550

@@ -553,6 +565,7 @@ static void http_redirect_to_https(void)
553565
.event_handler = _http_event_handler,
554566
.cert_pem = howsmyssl_com_root_cert_pem_start,
555567
};
568+
ESP_LOGI(TAG, "HTTP redirect to HTTPS request =>");
556569
esp_http_client_handle_t client = esp_http_client_init(&config);
557570
esp_err_t err = esp_http_client_perform(client);
558571

@@ -573,6 +586,7 @@ static void http_download_chunk(void)
573586
.url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/stream-bytes/8912",
574587
.event_handler = _http_event_handler,
575588
};
589+
ESP_LOGI(TAG, "HTTP chunk encoding request =>");
576590
esp_http_client_handle_t client = esp_http_client_init(&config);
577591
esp_err_t err = esp_http_client_perform(client);
578592

@@ -596,6 +610,7 @@ static void http_perform_as_stream_reader(void)
596610
esp_http_client_config_t config = {
597611
.url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get",
598612
};
613+
ESP_LOGI(TAG, "HTTP Stream reader request =>");
599614
esp_http_client_handle_t client = esp_http_client_init(&config);
600615
esp_err_t err;
601616
if ((err = esp_http_client_open(client, 0)) != ESP_OK) {
@@ -630,6 +645,7 @@ static void https_async(void)
630645
.is_async = true,
631646
.timeout_ms = 5000,
632647
};
648+
ESP_LOGI(TAG, "HTTPS async requests =>");
633649
esp_http_client_handle_t client = esp_http_client_init(&config);
634650
esp_err_t err;
635651
const char *post_data = "Using a Palantír requires a person with great strength of will and wisdom. The Palantíri were meant to "
@@ -685,6 +701,7 @@ static void https_with_invalid_url(void)
685701
.url = "https://not.existent.url",
686702
.event_handler = _http_event_handler,
687703
};
704+
ESP_LOGI(TAG, "HTTPS request with invalid url =>");
688705
esp_http_client_handle_t client = esp_http_client_init(&config);
689706
esp_err_t err = esp_http_client_perform(client);
690707

@@ -713,6 +730,7 @@ static void http_native_request(void)
713730
esp_http_client_config_t config = {
714731
.url = "http://"CONFIG_EXAMPLE_HTTP_ENDPOINT"/get",
715732
};
733+
ESP_LOGI(TAG, "HTTP native request =>");
716734
esp_http_client_handle_t client = esp_http_client_init(&config);
717735

718736
// GET Request
@@ -777,6 +795,7 @@ static void http_partial_download(void)
777795
.event_handler = _http_event_handler,
778796
.crt_bundle_attach = esp_crt_bundle_attach,
779797
};
798+
ESP_LOGI(TAG, "HTTP partial download =>");
780799
esp_http_client_handle_t client = esp_http_client_init(&config);
781800

782801
// Download a file excluding first 10 bytes

0 commit comments

Comments
 (0)