mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-05 22:08:23 +00:00
rebase and update file-transfer example
This commit is contained in:
1 parent
0fc0230364
commit
c6128094b6
1 file changed
+4
-2
@@ -71,7 +71,7 @@ static void cb(struct mg_connection *c, int ev, void *ev_data) {
|
|||||||
} else {
|
} else {
|
||||||
MG_DEBUG(("Got request, chunk len %lu", c->recv.len - n));
|
MG_DEBUG(("Got request, chunk len %lu", c->recv.len - n));
|
||||||
if ((fd = mg_fs_open(&mg_fs_posix, fpath, MG_FS_WRITE)) == NULL) {
|
if ((fd = mg_fs_open(&mg_fs_posix, fpath, MG_FS_WRITE)) == NULL) {
|
||||||
mg_http_reply(c, 400, "", "open failed: %d", errno);
|
mg_http_reply(c, 400, "", "open failed: %d\n", errno);
|
||||||
c->is_draining = 1; // Tell mongoose to close this connection
|
c->is_draining = 1; // Tell mongoose to close this connection
|
||||||
} else {
|
} else {
|
||||||
c->fn_data = fd;
|
c->fn_data = fd;
|
||||||
@@ -159,7 +159,9 @@ int main(int argc, char *argv[]) {
|
|||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
mg_log_set(s_debug_level);
|
mg_log_set(s_debug_level);
|
||||||
mg_mgr_init(&mgr);
|
mg_mgr_init(&mgr);
|
||||||
if (mg_http_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
|
// use mg_listen instead of mg_http_listen to be able to override the parser
|
||||||
|
// and shape buffering
|
||||||
|
if (mg_listen(&mgr, s_listening_address, cb, NULL) == NULL) {
|
||||||
MG_ERROR(("Cannot listen on %s.", s_listening_address));
|
MG_ERROR(("Cannot listen on %s.", s_listening_address));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user