Skip to content

A follow-up to PR 632 - #636

Merged
ivmarkov merged 2 commits into
masterfrom
pr-632
Nov 18, 2026
Merged

ivmarkov merged 2 commits into
masterfrom
pr-632

Conversation

@ivmarkov

Copy link
Copy Markdown
Collaborator

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 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo fmt command to ensure that all changed code is formatted correctly.
  • I have used cargo clippy command to ensure that all changed code passes latest Clippy nightly lints.
  • My changes were added to the CHANGELOG.md of 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 EspHttpConnection also sent the headers of the previous request which it did not set itself. This also means that an Authorization header could be sent to another host, because esp_http_client_set_url only replaces the Host header when the host changes.

Changes on top of #632:

  • The Host and User-Agent headers are not deleted. ESP-IDF sets both of them in esp_http_client_init, and it sets Host again 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 without Host is rejected by HTTP/1.1 servers, and some APIs reject a request without User-Agent. A caller's value for these two headers is therefore kept, as before.
  • The header name is moved into the list after esp_http_client_set_header, instead of being cloned.
  • Shorter code comments and CHANGELOG entry.

Testing

wackazong and others added 2 commits November 13, 2026 18:44
…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.
@ivmarkov
ivmarkov merged commit 87ff017 into master Nov 18, 2026
67 of 68 checks passed
@ivmarkov
ivmarkov deleted the pr-632 branch November 18, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants