diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index c7d2c28ffa..d54558ec16 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -691,6 +691,11 @@ static bool init_common_tcp_transport(esp_http_client_handle_t client, const esp } esp_transport_tcp_set_interface_name(transport, client->if_name); } +#if CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS + if (config->alpn_protos) { + esp_transport_ssl_set_alpn_protocol(transport, config->alpn_protos); + } +#endif return true; } diff --git a/components/esp_http_client/include/esp_http_client.h b/components/esp_http_client/include/esp_http_client.h index 510b09889f..f5c4b69c83 100644 --- a/components/esp_http_client/include/esp_http_client.h +++ b/components/esp_http_client/include/esp_http_client.h @@ -178,6 +178,10 @@ typedef struct { int keep_alive_interval; /*!< Keep-alive interval time. Default is 5 (second) */ int keep_alive_count; /*!< Keep-alive packet retry send count. Default is 3 counts */ struct ifreq *if_name; /*!< The name of interface for data to go through. Use the default interface without setting */ +#if CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS + const char **alpn_protos; /*!< Application protocols required for HTTP2. If HTTP2/ALPN support is required, a list of protocols that should be negotiated. The format is length followed by protocol + name. For the most common cases the following is ok: const char **alpn_protos = { "h2", NULL }; - where 'h2' is the protocol name */ +#endif #if CONFIG_ESP_TLS_USE_SECURE_ELEMENT bool use_secure_element; /*!< Enable this option to use secure element */ #endif