|
25 | 25 |
|
26 | 26 | static const char *TAG = "websocket_client";
|
27 | 27 |
|
| 28 | +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0) |
| 29 | +// Features supported in 5.5.0 |
| 30 | +#define WS_TRANSPORT_STORE_RESPONSE_HEADERS 1 |
| 31 | +#endif |
| 32 | + |
28 | 33 | #define WEBSOCKET_TCP_DEFAULT_PORT (80)
|
29 | 34 | #define WEBSOCKET_SSL_DEFAULT_PORT (443)
|
30 | 35 | #define WEBSOCKET_BUFFER_SIZE_BYTE (1024)
|
@@ -101,6 +106,8 @@ typedef struct {
|
101 | 106 | const char *cert_common_name;
|
102 | 107 | esp_err_t (*crt_bundle_attach)(void *conf);
|
103 | 108 | esp_transport_handle_t ext_transport;
|
| 109 | + char *response_headers; |
| 110 | + size_t response_headers_len; |
104 | 111 | } websocket_config_storage_t;
|
105 | 112 |
|
106 | 113 | typedef enum {
|
@@ -474,7 +481,11 @@ static esp_err_t set_websocket_transport_optional_settings(esp_websocket_client_
|
474 | 481 | .user_agent = client->config->user_agent,
|
475 | 482 | .headers = client->config->headers,
|
476 | 483 | .auth = client->config->auth,
|
477 |
| - .propagate_control_frames = true |
| 484 | + .propagate_control_frames = true, |
| 485 | +#if WS_TRANSPORT_STORE_RESPONSE_HEADERS |
| 486 | + .response_headers = client->config->response_headers, |
| 487 | + .response_headers_len = client->config->response_headers_len |
| 488 | +#endif |
478 | 489 | };
|
479 | 490 | return esp_transport_ws_set_config(trans, &config);
|
480 | 491 | }
|
@@ -725,7 +736,8 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie
|
725 | 736 | client->config->cert_common_name = config->cert_common_name;
|
726 | 737 | client->config->crt_bundle_attach = config->crt_bundle_attach;
|
727 | 738 | client->config->ext_transport = config->ext_transport;
|
728 |
| - |
| 739 | + client->config->response_headers = config->response_headers; |
| 740 | + client->config->response_headers_len = config->response_headers_len; |
729 | 741 | if (config->uri) {
|
730 | 742 | if (esp_websocket_client_set_uri(client, config->uri) != ESP_OK) {
|
731 | 743 | ESP_LOGE(TAG, "Invalid uri");
|
|
0 commit comments