Skip to content

Conversation

@bryghtlabs-richard
Copy link
Contributor

@bryghtlabs-richard bryghtlabs-richard commented Jun 12, 2025

Description

Send a new event for each HTTP header-line received, so that the caller may extract interesting headers and cookies. In my case, this is needed for supporting F5 and Amazon ALB cookie-based load-balancers.

Related

Depends on espressif/esp-idf#16119
Closes #715

Testing

Confirmed I can print out the needed header-lines.

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

Emit WEBSOCKET_EVENT_HEADER_RECEIVED for each pre-upgrade HTTP header via a transport header callback (IDF ≥ 6), and update examples to handle it.

  • Core (websocket client):
    • Add pre-upgrade HTTP header callback: define websocket_header_hook() and, when supported, pass .header_hook and .header_user_context to esp_transport_ws_config_t, dispatching WEBSOCKET_EVENT_HEADER_RECEIVED for each header line.
  • API:
    • Introduce WS_TRANSPORT_HEADER_CALLBACK_SUPPORT (enabled for ESP_IDF_VERSION >= 6.0.0).
    • Add WEBSOCKET_EVENT_HEADER_RECEIVED to esp_websocket_event_id_t (behind the feature flag).
  • Examples:
    • Update examples/linux and examples/target event handlers to log WEBSOCKET_EVENT_HEADER_RECEIVED when available.

Written by Cursor Bugbot for commit 3a9529b. This will update automatically on new commits. Configure here.

@bryghtlabs-richard bryghtlabs-richard force-pushed the feat/websocket-response-headers branch from 6be5991 to f96e373 Compare June 12, 2025 18:41
@glmfe
Copy link
Collaborator

glmfe commented Sep 26, 2025

Hi @bryghtlabs-richard,

we merged the dependencies for this PR, (espressif/esp-idf#16199, espressif/esp-idf#16119).
Please, use the current head of IDF and also add:

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
// Features supported in 6.0.0
#define WS_TRANSPORT_HEADER_CALLBACK_SUPPORT    1
#endif

then guard all the codes using:

#if WS_TRANSPORT_REDIRECT_HEADER_SUPPORT
`... code section...`
#endif // WS_TRANSPORT_REDIRECT_HEADER_SUPPORT

Thanks!

@github-actions github-actions bot changed the title feat(websocket): add WEBSOCKET_EVENT_HEADER_RECEIVED feat(websocket): add WEBSOCKET_EVENT_HEADER_RECEIVED (IDFGH-16539) Sep 26, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Sep 26, 2025
@bryghtlabs-richard bryghtlabs-richard force-pushed the feat/websocket-response-headers branch from 90cef3a to 3a9529b Compare September 29, 2025 20:32
@bryghtlabs-richard
Copy link
Contributor Author

then guard all the codes using:

It is done and ready for your review.

@glmfe , should ESP-IDF keep both APIs (including 1d71a9e8114fba8d22e96694 API), or only support the per-header callback one going forward? I think once 6.0.0 is released, we'll need to support everything in it going forward.

@glmfe
Copy link
Collaborator

glmfe commented Sep 29, 2025

then guard all the codes using:

It is done and ready for your review.

@glmfe , should ESP-IDF keep both APIs (including 1d71a9e8114fba8d22e96694 API), or only support the per-header callback one going forward? I think once 6.0.0 is released, we'll need to support everything in it going forward.

Thanks for the updates, LGTM

about the other API, my guess is that we are going to deprecate it later on since we already entered the code freeze for IDF 6.0. But I'll have to allign internally

@bryghtlabs-richard bryghtlabs-richard force-pushed the feat/websocket-response-headers branch from 3a9529b to 57d48bb Compare October 3, 2025 13:22
@glmfe
Copy link
Collaborator

glmfe commented Oct 21, 2025

Hi @bryghtlabs-richard,

we just merged a fix for the pipeline issue, please, rebase your brach.

BR

Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
@bryghtlabs-richard bryghtlabs-richard force-pushed the feat/websocket-response-headers branch from 57d48bb to b13064d Compare October 22, 2025 14:59
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@glmfe glmfe merged commit 18f0d02 into espressif:master Oct 22, 2025
82 of 83 checks passed
gabsuren pushed a commit to gabsuren/esp-protocols-1 that referenced this pull request Nov 13, 2025
1.6.0
Features
- add WEBSOCKET_EVENT_HEADER_RECEIVED (espressif#827) (18f0d02, espressif#715)
- enhance example with docs, pytest setup, and standalone test server     - Add comprehensive README with TOC and quick start     - Add pytest setup and certificate generation scripts     - Add standalone WebSocket test server with TLS support     - Add troubleshooting and multiple testing approaches (cad527d)
- Add websocket HTTP redirect (ce1560a)
Bug Fixes
- remove redundant timeout check in client task loop (1e83bee)
- fix PING timing - enable periodic PING during active traffic (7f42432)
- Update linux build docs on required libs (e52a575)
- clean up component dependencies - Remove unused 'json', 'nvs_flash', 'esp_stubs', dependency from Linux build configuration - Add cJSON dependency to target example's idf_component.yml (d665e6f)
- fix relying on asprintf() to NULL strp on failure (54eb002)
- Update Remaining Websocket Echo Server (espressif#893) (18faeb3)
- avoid long stopping time when waiting to auto-reconnect (2432e41)
- Update Websocket Echo Server (94bd5b0)
Updated
- ci(common): Update test component dir for IDFv6.0 (18418c8)
@gabsuren gabsuren mentioned this pull request Nov 13, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[websocket]: ability to read connection upgrade headers (IDFGH-14252)

3 participants