[http_request] Fix usage of http response body (#17713)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Grégoire Seux
2026-07-21 08:18:16 +12:00
committed by Jesse Hills
co-authored by J. Nick Koston
parent 5a86e26f68
commit 7738464f0b
2 changed files with 20 additions and 2 deletions
@@ -59,6 +59,24 @@ esphome:
id: test_regression_light
brightness: 100%
effect: "None"
- http_request.get:
url: https://esphome.io
capture_response: true
on_response:
then:
# Regression test: http_request.post with json: (dict variant) inside
# on_response of a capture_response: true request puts std::string&
# (body) into the nested action's Ts..., which exposes a
# const-correctness bug in HttpRequestSendAction::play() where
# encode_json_ receives const copies of non-const reference args.
- http_request.post:
url: https://esphome.io
json:
status: "ok"
# Same with json: lambda variant, exercises json_func_ path
- http_request.post:
url: https://esphome.io
json: !lambda "root[\"status\"] = \"ok\";"
http_request:
useragent: esphome/tagreader