mirror of https://github.com/arendst/Tasmota.git
Berry `webserver.header` to read browser sent headers (#20447)
This commit is contained in:
parent
8712aba3c5
commit
85fb54fe8d
|
@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
|
||||||
- Berry add `string` to `bytes()` (#20420)
|
- Berry add `string` to `bytes()` (#20420)
|
||||||
- Berry button to dynamically load GPIO Viewer with Berry backend (#20424)
|
- Berry button to dynamically load GPIO Viewer with Berry backend (#20424)
|
||||||
- Berry `debug_panel.tapp` to display real-time heap and wifi rssi
|
- Berry `debug_panel.tapp` to display real-time heap and wifi rssi
|
||||||
|
- Berry `webserver.header` to read browser sent headers
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern int w_webserver_arg(bvm *vm);
|
||||||
extern int w_webserver_arg_name(bvm *vm);
|
extern int w_webserver_arg_name(bvm *vm);
|
||||||
extern int w_webserver_has_arg(bvm *vm);
|
extern int w_webserver_has_arg(bvm *vm);
|
||||||
|
|
||||||
|
extern int w_webserver_header(bvm *vm);
|
||||||
|
|
||||||
// To allow a full restart of the Berry VM, we need to supplement the webserver Request Handler
|
// To allow a full restart of the Berry VM, we need to supplement the webserver Request Handler
|
||||||
// model from Arduino framework.
|
// model from Arduino framework.
|
||||||
|
@ -160,6 +161,8 @@ module webserver (scope: global) {
|
||||||
arg, func(w_webserver_arg)
|
arg, func(w_webserver_arg)
|
||||||
arg_name, func(w_webserver_arg_name)
|
arg_name, func(w_webserver_arg_name)
|
||||||
has_arg, func(w_webserver_has_arg)
|
has_arg, func(w_webserver_has_arg)
|
||||||
|
|
||||||
|
header, func(w_webserver_header)
|
||||||
}
|
}
|
||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
#include "be_fixed_webserver.h"
|
#include "be_fixed_webserver.h"
|
||||||
|
|
|
@ -335,6 +335,23 @@ extern "C" {
|
||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Berry: `webserver.header(name:string) -> string or nil`
|
||||||
|
int32_t w_webserver_header(struct bvm *vm);
|
||||||
|
int32_t w_webserver_header(struct bvm *vm) {
|
||||||
|
int32_t argc = be_top(vm); // Get the number of arguments
|
||||||
|
if (argc >= 1 && be_isstring(vm, 1)) {
|
||||||
|
const char * header_name = be_tostring(vm, 1);
|
||||||
|
String header = Webserver->header(header_name);
|
||||||
|
if (header.length() > 0) {
|
||||||
|
be_pushstring(vm, header.c_str());
|
||||||
|
be_return(vm);
|
||||||
|
} else {
|
||||||
|
be_return_nil(vm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
be_raise(vm, kTypeError, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
Loading…
Reference in New Issue