diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7eff7ac..69f7aaa97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - Extended Tariff command for forced tariff (#18080) - Berry support for Tensorflow Lite (TFL) by Christiaan Baars (#18119) - Zigbee send Tuya 'magic spell' to unlock devices when pairing (#18144) +- Berry add `wc.set_follow_redirects(bool)` ### Breaking Changed - Shelly Pro 4PM using standard MCP23xxx driver and needs one time Auto-Configuration diff --git a/lib/libesp32/berry_tasmota/src/be_webclient_lib.c b/lib/libesp32/berry_tasmota/src/be_webclient_lib.c index ace4499a2..cacd74ad1 100644 --- a/lib/libesp32/berry_tasmota/src/be_webclient_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_webclient_lib.c @@ -14,6 +14,7 @@ extern int wc_urlencode(bvm *vm); extern int wc_begin(bvm *vm); extern int wc_set_timeouts(bvm *vm); extern int wc_set_useragent(bvm *vm); +extern int wc_set_follow_redirects(bvm *vm); extern int wc_set_auth(bvm *vm); extern int wc_connected(bvm *vm); extern int wc_close(bvm *vm); @@ -47,6 +48,7 @@ class be_class_webclient (scope: global, name: webclient) { begin, func(wc_begin) set_timeouts, func(wc_set_timeouts) set_useragent, func(wc_set_useragent) + set_follow_redirects, func(wc_set_follow_redirects) set_auth, func(wc_set_auth) close, func(wc_close) add_header, func(wc_addheader) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino index 198103fd3..546f1871e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_webclient.ino @@ -259,6 +259,20 @@ extern "C" { be_raise(vm, kTypeError, nullptr); } + // wc.set_follow_redirects(bool) -> self + int32_t wc_set_follow_redirects(struct bvm *vm); + int32_t wc_set_follow_redirects(struct bvm *vm) { + int32_t argc = be_top(vm); + if (argc >= 2 && be_isbool(vm, 2)) { + HTTPClientLight * cl = wc_getclient(vm); + bbool follow = be_tobool(vm, 2); + cl->setFollowRedirects(follow ? HTTPC_STRICT_FOLLOW_REDIRECTS : HTTPC_DISABLE_FOLLOW_REDIRECTS); + be_pushvalue(vm, 1); + be_return(vm); /* return self */ + } + be_raise(vm, kTypeError, nullptr); + } + // wc.wc_set_auth(auth:string | (user:string, password:string)) -> self int32_t wc_set_auth(struct bvm *vm); int32_t wc_set_auth(struct bvm *vm) {