Skip to content

Conversation

@bryghtlabs-richard
Copy link
Contributor

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

Description

Add a callback for each line of header responses in the Websocket HTTP->WS transport upgrade. This is necessary to support AWS ALB and F5 cookie-based load-balancer sticky-sessions.

Related

Please see espressif/esp-protocols#715 . There is another part of this patchset espressif/esp-protocols#827, as well as a different implementation espressif/esp-protocols#794

Testing

  • Existing "Sec-WebSocket-Accept" header-parsing was tested by connecting to a websocket. Failure was tested by intentionally setting server_key = NULL and confirming we still reject the connection.
  • New headers were tested by logging each header-line with ESP_LOGI() at the next layer up, in the esp_websocket_client.

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.

bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Jun 12, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Jun 12, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Jun 12, 2025
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/ws_transport_header_callbacks branch from f5ff595 to f8c65f8 Compare June 12, 2025 18:46
@github-actions github-actions bot changed the title feat(ws_transport): add header callback hook feat(ws_transport): add header callback hook (IDFGH-15479) Jun 12, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 12, 2025
Buffer separately to simplify future improvements.
Move to a line-by-line header parser.
Support a callback hook for each header-line.
Migrate "Location" and "Sec-WebSocket-Accept" parsing.

Part of espressif/esp-protocols#715
@bryghtlabs-richard bryghtlabs-richard force-pushed the feat/ws_transport_header_callbacks branch from f8c65f8 to 0245c5c Compare June 26, 2025 16:06
@github-actions
Copy link

github-actions bot commented Jun 26, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello bryghtlabs-richard, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against 0245c5c

@glmfe
Copy link
Collaborator

glmfe commented Aug 27, 2025

sha=0245c5c863fd1bf08ed9fbd913f8cccb297948cc

@euripedesrocha euripedesrocha added PR-Sync-Merge Pull request sync as merge commit and removed PR-Sync-Merge Pull request sync as merge commit labels Aug 28, 2025
@euripedesrocha
Copy link
Collaborator

sha=0245c5c863fd1bf08ed9fbd913f8cccb297948cc

@euripedesrocha euripedesrocha added the PR-Sync-Merge Pull request sync as merge commit label Aug 28, 2025
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new labels Aug 29, 2025
@glmfe
Copy link
Collaborator

glmfe commented Sep 1, 2025

Hi @bryghtlabs-richard,

I've got some comments from colleagues internally that I'll post them here as well

* - ESP_OK on success
* - One of the error codes
*/
esp_err_t esp_transport_ws_set_header_userp(esp_transport_handle_t t, void * userp);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to set this pointer in a separated function? Could it be a context in the set header hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it could. I'm fine with either way.

err = esp_transport_ws_set_header_hook(t, config->header_hook);
ESP_TRANSPORT_ERR_OK_CHECK(TAG, err, return err;)
}
if (config->header_userp) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if user set this, but the hook isn't configured, should we warn? Is the idea that the context for the callback could change in between calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I would worry about it, but if it's preferred we could. I don't expect anyone would change the header_userp context in-between headers, given that their ordering isn't guaranteed.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable Resolution: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed labels Sep 12, 2025
@espressif-bot espressif-bot removed the Resolution: NA Issue resolution is unavailable label Sep 12, 2025
@glmfe
Copy link
Collaborator

glmfe commented Sep 26, 2025

Accepted as 11f8534

Thanks for your contribution!

@glmfe glmfe closed this Sep 26, 2025
bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Sep 29, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Oct 3, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
bryghtlabs-richard added a commit to bryghtlabs-richard/esp-protocols that referenced this pull request Oct 22, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes espressif#715
glmfe pushed a commit to espressif/esp-protocols that referenced this pull request Oct 22, 2025
Send a new event for each HTTP header-line received.

Depends on espressif/esp-idf#16119
Closes #715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Sync-Merge Pull request sync as merge commit Resolution: Done Issue is done internally Status: Done Issue is done internally

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants