-
My goal is:
My goal is that mongoose http/https server works on my device. -
My actions are:
I used simplest_web_server.c with lwip.
mongoose’s configuration is as follows.
#define CS_PLATFORM 0
#define MG_DISABLE_CGI
#define MG_LWIP 1
#define MG_ENABLE_FILESYSTEM 1
But it didn’t work correctly, because timeout error was occured.
- The result I see is:
I modified source code, it works correctly.
patch-files is as follows.
diff --git a/examples/simplest_web_server/simplest_web_server.c b/examples/simplest_web_server/simplest_web_server.c
index 94d5933…90a37f9 100644
— a/examples/simplest_web_server/simplest_web_server.c
+++ b/examples/simplest_web_server/simplest_web_server.c
@@ -9,6 +9,7 @@ static struct mg_serve_http_opts s_http_server_opts;
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
if (ev == MG_EV_HTTP_REQUEST) {
mg_serve_http(nc, (struct http_message *) p, s_http_server_opts);
- nc->flags |= MG_F_SEND_AND_CLOSE;
}
}diff --git a/mongoose.c b/mongoose.c
index 9571d57…6eb477b 100644
— a/mongoose.c
+++ b/mongoose.c
@@ -3009,7 +3009,8 @@ static int mg_recv_tcp(struct mg_connection *nc, char *buf, size_t len) {
mbuf_trim(&nc->recv_mbuf);
mg_call(nc, NULL, nc->user_data, MG_EV_RECV, &n);
} else if (n < 0) {
- if( !(nc->flags & MG_F_SEND_AND_CLOSE) )
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
mbuf_trim(&nc->recv_mbuf);
return n;
- My expectation & question is:
Is my idea correct?
Please give me your good advice.
Best regards.