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

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 3a9529b to 57d48bb Compare October 3, 2025 13:22
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