Small improvements to the simple web server.

This commit is contained in:
Relintai 2022-08-26 14:52:56 +02:00
parent 0cfc5ed610
commit 76141ee7e7
2 changed files with 17 additions and 14 deletions

View File

@ -550,20 +550,23 @@ int HTTPParser::on_multipart_part_data_end_cb() {
#endif
if (_multipart_form_is_file) {
PoolByteArray file_data;
int len = _multipart_form_data.size();
file_data.resize(len);
PoolByteArray::Write w = file_data.write();
const char *r = _multipart_form_data.ptr();
for (int i = 0; i < len; i++) {
w[i] = r[i];
if (_multipart_form_data.size() > 0) {
PoolByteArray file_data;
int len = _multipart_form_data.size();
file_data.resize(len);
PoolByteArray::Write w = file_data.write();
const char *r = _multipart_form_data.ptr();
for (int i = 0; i < len; i++) {
w[i] = r[i];
}
w.release();
_request->add_file(_multipart_form_name, _multipart_form_filename, file_data);
}
w.release();
_request->add_file(_multipart_form_name, _multipart_form_filename, file_data);
} else {
_request->add_parameter(_multipart_form_name, String(_multipart_form_data.ptr()));
String s = _multipart_form_data.ptr();
_request->add_parameter(_multipart_form_name, s);
}
_multipart_form_is_file = false;

View File

@ -1,16 +1,16 @@
#include "simple_web_server_request.h"
#include "core/object/object.h"
#include "modules/web/http/web_server.h"
#include "modules/web/http/web_server_cookie.h"
#include "core/object/object.h"
#include "modules/web/http/http_session.h"
#include "modules/web/http/http_session_manager.h"
#include "modules/web/http/web_node.h"
#include "modules/web/http/web_permission.h"
#include "http_server_simple.h"
#include "modules/web/http/web_permission.h"
String SimpleWebServerRequest::get_cookie(const String &key) {
for (int i = 0; i < _cookies.size(); ++i) {