-
Notifications
You must be signed in to change notification settings - Fork 8k
feat(ws_transport): add header callback hook (IDFGH-15479) #16119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ws_transport): add header callback hook (IDFGH-15479) #16119
Conversation
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
f5ff595 to
f8c65f8
Compare
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
f8c65f8 to
0245c5c
Compare
👋 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 ...
Review and merge process you can expect ...
|
|
sha=0245c5c863fd1bf08ed9fbd913f8cccb297948cc |
|
sha=0245c5c863fd1bf08ed9fbd913f8cccb297948cc |
|
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Accepted as 11f8534 Thanks for your contribution! |
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes espressif#715
Send a new event for each HTTP header-line received. Depends on espressif/esp-idf#16119 Closes #715
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
server_key = NULLand confirming we still reject the connection.ESP_LOGI()at the next layer up, in the esp_websocket_client.Checklist
Before submitting a Pull Request, please ensure the following: