|
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_GET_RESPONSE_HEADER 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)
|
@@ -85,6 +90,7 @@ typedef struct {
|
85 | 90 | char *subprotocol;
|
86 | 91 | char *user_agent;
|
87 | 92 | char *headers;
|
| 93 | + const char *response_headers; |
88 | 94 | int pingpong_timeout_sec;
|
89 | 95 | size_t ping_interval_sec;
|
90 | 96 | const char *cert;
|
@@ -1020,6 +1026,9 @@ static void esp_websocket_client_task(void *pv)
|
1020 | 1026 | client->config->host,
|
1021 | 1027 | client->config->port,
|
1022 | 1028 | client->config->network_timeout_ms);
|
| 1029 | +#if WS_TRANSPORT_GET_RESPONSE_HEADER |
| 1030 | + client->config->response_headers = esp_transport_ws_get_response_header(client->transport); |
| 1031 | +#endif |
1023 | 1032 | if (result < 0) {
|
1024 | 1033 | esp_tls_error_handle_t error_handle = esp_transport_get_error_handle(client->transport);
|
1025 | 1034 | client->error_handle.esp_ws_handshake_status_code = esp_transport_ws_get_upgrade_request_status(client->transport);
|
@@ -1341,6 +1350,18 @@ int esp_websocket_client_get_reconnect_timeout(esp_websocket_client_handle_t cli
|
1341 | 1350 | return client->wait_timeout_ms;
|
1342 | 1351 | }
|
1343 | 1352 |
|
| 1353 | +#if WS_TRANSPORT_GET_RESPONSE_HEADER |
| 1354 | +const char* esp_websocket_client_get_response_header(esp_websocket_client_handle_t client) |
| 1355 | +{ |
| 1356 | + if (client == NULL) { |
| 1357 | + ESP_LOGW(TAG, "Client was not initialized"); |
| 1358 | + return NULL; |
| 1359 | + } |
| 1360 | + |
| 1361 | + return client->config->response_headers; |
| 1362 | +} |
| 1363 | +#endif |
| 1364 | + |
1344 | 1365 | esp_err_t esp_websocket_client_set_reconnect_timeout(esp_websocket_client_handle_t client, int reconnect_timeout_ms)
|
1345 | 1366 | {
|
1346 | 1367 | if (client == NULL) {
|
|
0 commit comments