This commit is contained in:
Sergey Lyubka committed 2022-05-17 19:29:53 +01:00
1 parent cac7007069
commit 47e15a3d47
3 files changed
+11 -2

No files matched your search

+5 -2
View File
@@ -31,7 +31,8 @@ static bool update_config(struct mg_http_message *hm, struct config *cfg) {
}
if (mg_http_get_var(&hm->body, "value2", buf, sizeof(buf)) > 0) {
free(cfg->value2);
cfg->value2 = strdup(buf);
cfg->value2 = malloc(strlen(buf) + 1);
strcpy(cfg->value2, buf);
changed = true;
}
return changed;
@@ -82,7 +83,9 @@ void device_dashboard_fn(struct mg_connection *c, int ev, void *ev_data,
struct user *u = getuser(hm);
// MG_INFO(("%p [%.*s] auth %s", c->fd, (int) hm->uri.len, hm->uri.ptr,
// u ? u->name : "NULL"));
if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
if (mg_http_match_uri(hm, "/api/hi")) {
mg_http_reply(c, 200, "", "hi\n"); // Testing endpoint
} else if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
// All URIs starting with /api/ must be authenticated
mg_printf(c, "%s", "HTTP/1.1 403 Denied\r\nContent-Length: 0\r\n\r\n");
} else if (mg_http_match_uri(hm, "/api/config/get")) {
+3
View File
@@ -3288,6 +3288,9 @@ static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
if (n > 0) setlocaddr(FD(c), &c->loc);
} else {
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
#if MG_ARCH == MG_ARCH_RTX
if (n == BSD_EWOULDBLOCK) return 0;
#endif
}
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
}
+3
View File
@@ -152,6 +152,9 @@ static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
if (n > 0) setlocaddr(FD(c), &c->loc);
} else {
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
#if MG_ARCH == MG_ARCH_RTX
if (n == BSD_EWOULDBLOCK) return 0;
#endif
}
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
}