diff --git a/examples/netcat/Makefile b/examples/netcat/Makefile index aeffe7f2..2a99cc08 100644 --- a/examples/netcat/Makefile +++ b/examples/netcat/Makefile @@ -1,4 +1,4 @@ PROG = nc -MODULE_CFLAGS=-DMG_ENABLE_THREADS +MODULE_CFLAGS=-DMG_ENABLE_THREADS -DMG_DISABLE_HTTP SSL_LIB=openssl include ../examples.mk diff --git a/examples/restful_server/Makefile b/examples/restful_server/Makefile index 3ab02afd..f481ef30 100644 --- a/examples/restful_server/Makefile +++ b/examples/restful_server/Makefile @@ -1,2 +1,3 @@ PROG = restful_server +MODULE_CFLAGS=-DMG_ENABLE_THREADS -DMG_DISABLE_HTTP_WEBSOCKET include ../examples.mk diff --git a/mongoose.c b/mongoose.c index 9635fcec..3bc77d20 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5146,8 +5146,9 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) { mg_call(nc, nc->handler, MG_EV_WEBSOCKET_HANDSHAKE_DONE, NULL); mg_websocket_handler(nc, MG_EV_RECV, ev_data); } + } #endif /* MG_DISABLE_HTTP_WEBSOCKET */ - } else if (hm->message.len <= io->len) { + else if (hm->message.len <= io->len) { int trigger_ev = nc->listener ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY; /* Whole HTTP message is fully buffered, call event handler */ @@ -7764,6 +7765,7 @@ struct mg_connection *mg_connect_http(struct mg_mgr *mgr, post_data); } +#ifndef MG_DISABLE_HTTP_WEBSOCKET struct mg_connection *mg_connect_ws_opt(struct mg_mgr *mgr, mg_event_handler_t ev_handler, struct mg_connect_opts opts, @@ -7792,6 +7794,7 @@ struct mg_connection *mg_connect_ws(struct mg_mgr *mgr, memset(&opts, 0, sizeof(opts)); return mg_connect_ws_opt(mgr, ev_handler, opts, url, protocol, extra_headers); } +#endif /* MG_DISABLE_HTTP_WEBSOCKET */ size_t mg_parse_multipart(const char *buf, size_t buf_len, char *var_name, size_t var_name_len, char *file_name, diff --git a/mongoose.h b/mongoose.h index c54e05a7..74080735 100644 --- a/mongoose.h +++ b/mongoose.h @@ -2127,10 +2127,12 @@ struct mg_http_multipart_part { #define MG_EV_HTTP_CHUNK 102 /* struct http_message * */ #define MG_EV_SSI_CALL 105 /* char * */ +#ifndef MG_DISABLE_HTTP_WEBSOCKET #define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST 111 /* NULL */ #define MG_EV_WEBSOCKET_HANDSHAKE_DONE 112 /* NULL */ #define MG_EV_WEBSOCKET_FRAME 113 /* struct websocket_message * */ #define MG_EV_WEBSOCKET_CONTROL_FRAME 114 /* struct websocket_message * */ +#endif #ifdef MG_ENABLE_HTTP_STREAMING_MULTIPART #define MG_EV_HTTP_MULTIPART_REQUEST 121 /* struct http_message */ @@ -2184,6 +2186,7 @@ struct mg_http_multipart_part { */ void mg_set_protocol_http_websocket(struct mg_connection *nc); +#ifndef MG_DISABLE_HTTP_WEBSOCKET /* * Send websocket handshake to the server. * @@ -2289,6 +2292,7 @@ void mg_send_websocket_framev(struct mg_connection *nc, int op_and_flags, */ void mg_printf_websocket_frame(struct mg_connection *nc, int op_and_flags, const char *fmt, ...); +#endif /* MG_DISABLE_HTTP_WEBSOCKET */ /* * Send buffer `buf` of size `len` to the client using chunked HTTP encoding.