Berry add `wc.set_follow_redirects(bool)` (#18165)

This commit is contained in:
s-hadinger 2023-03-11 19:48:39 +01:00 committed by GitHub
parent c74c92baed
commit 4aa9aebae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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) {