Repository navigation
Conversation
…tion `esp_http_client_set_header` keeps a header on the client handle until it is deleted, so a second request on the same `EspHttpConnection` also sent every header of the first that it did not set itself, for example a `Range` header from an earlier download or an `Authorization` header. `initiate_request` now remembers the names of the headers it set and deletes them before setting the next request's. Not `esp_http_client_delete_all_headers`: ESP-IDF stores its own `Host` and `User-Agent` in the same list.
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo fmtcommand to ensure that all changed code is formatted correctly.cargo clippycommand to ensure that all changed code passes latest Clippy nightly lints.CHANGELOG.mdof the affected crate(s) in the proper section.Pull Request Details 📖
Description
This is #632 by @wackazong, with a few changes on top. Their commit is kept as it is, and the changes are in a separate commit. Supersedes #632.
#632 fixes a real problem. ESP-IDF keeps request headers on the client handle until they are deleted, so a request on a reused
EspHttpConnectionalso sent the headers of the previous request which it did not set itself. This also means that anAuthorizationheader could be sent to another host, becauseesp_http_client_set_urlonly replaces theHostheader when the host changes.Changes on top of #632:
HostandUser-Agentheaders are not deleted. ESP-IDF sets both of them inesp_http_client_init, and it setsHostagain only when the host changes. So if a request overrides one of them, deleting it would make the next request go out without it. A request withoutHostis rejected by HTTP/1.1 servers, and some APIs reject a request withoutUser-Agent. A caller's value for these two headers is therefore kept, as before.esp_http_client_set_header, instead of being cloned.Testing
cargo clippy -p esp-idf-svc -- -Dwarningsforriscv32imc-esp-espidfwith ESP-IDF v5.5.5. They were not run on a device.