Commit e928f364 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

MG_DISABLE_HTTP(|_SSI|_WEBSOCKET) -> MG_ENABLE$1

Factor out SSI and WS code from http.c

HTTP + WS are enabled by default, but MQTT is built without HTTP
support as a compilation test.

PUBLISHED_FROM=925ed9a55abb193ed7deac1c9675a0e5b35dca50
parent fcb94a17
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
title: Disabling flags title: Disabling flags
--- ---
- `MG_DISABLE_HTTP_WEBSOCKET` disable HTTP + WebSocket protocol support
- `MG_DISABLE_HTTP_DIGEST_AUTH` disable HTTP Digest (MD5) authorisation support - `MG_DISABLE_HTTP_DIGEST_AUTH` disable HTTP Digest (MD5) authorisation support
- `MG_DISABLE_SHA1` disable SHA1 support (used by WebSocket) - `MG_DISABLE_SHA1` disable SHA1 support (used by WebSocket)
- `MG_DISABLE_MD5` disable MD5 support (used by HTTP auth) - `MG_DISABLE_MD5` disable MD5 support (used by HTTP auth)
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
title: Enabling flags title: Enabling flags
--- ---
- `MG_ENABLE_CGI` Enable CGI support - `MG_ENABLE_SSL` Enable [SSL/TLS support](https://docs.cesanta.com/mongoose/master/#/http/ssl.md/) (OpenSSL API)
- `MG_ENABLE_SSL` Enable SSL/TLS support (OpenSSL API)
- `MG_ENABLE_IPV6` Enable IPV6 support - `MG_ENABLE_IPV6` Enable IPV6 support
- `MG_ENABLE_MQTT` enable MQTT client - `MG_ENABLE_MQTT` enable [MQTT client](https://docs.cesanta.com/mongoose/master/#/mqtt/client_example.md/)
- `MG_ENABLE_MQTT_BROKER` enable MQTT broker - `MG_ENABLE_MQTT_BROKER` enable [MQTT broker](https://docs.cesanta.com/mongoose/master/#/mqtt/server_example.md/)
- `MG_ENABLE_DNS_SERVER` enable DNS server - `MG_ENABLE_DNS_SERVER` enable DNS server
- `MG_ENABLE_COAP` enable CoAP protocol - `MG_ENABLE_COAP` enable CoAP protocol
- `MG_ENABLE_HTTP` Enable HTTP protocol support (on by default, set to 0 to disable)
- `MG_ENABLE_HTTP_CGI` Enable [CGI](https://docs.cesanta.com/mongoose/master/#/http/cgi.md/) support
- `MG_ENABLE_HTTP_SSI` Enable [Server SIde Includes](https://docs.cesanta.com/mongoose/master/#/http/ssi.md/) support
- `MG_ENABLE_HTTP_WEBDAV` enable WebDAV extensions to HTTP - `MG_ENABLE_HTTP_WEBDAV` enable WebDAV extensions to HTTP
- `MG_ENABLE_HTTP_WEBSOCKET` enable WebSocket extension to HTTP (on by default, =0 to disable)
- `MG_ENABLE_GETADDRINFO` enable `getaddrinfo()` in `mg_resolve2()` - `MG_ENABLE_GETADDRINFO` enable `getaddrinfo()` in `mg_resolve2()`
- `MG_ENABLE_THREADS` enable `mg_start_thread()` API - `MG_ENABLE_THREADS` enable `mg_start_thread()` API
PROG = mqtt_broker PROG = mqtt_broker
MODULE_CFLAGS = -DMG_ENABLE_MQTT_BROKER MODULE_CFLAGS = -DMG_ENABLE_MQTT_BROKER -DMG_ENABLE_HTTP=0
SSL_LIB=openssl SSL_LIB=openssl
include ../examples.mk include ../examples.mk
PROG = mqtt_client PROG = mqtt_client
MODULE_CFLAGS = -DMG_ENABLE_MQTT MODULE_CFLAGS = -DMG_ENABLE_MQTT -DMG_ENABLE_HTTP=0
SSL_LIB=openssl SSL_LIB=openssl
include ../examples.mk include ../examples.mk
PROG = restful_server PROG = restful_server
MODULE_CFLAGS=-DMG_ENABLE_THREADS -DMG_DISABLE_HTTP_WEBSOCKET MODULE_CFLAGS=-DMG_ENABLE_THREADS -DMG_ENABLE_HTTP_WEBSOCKET=0
include ../examples.mk include ../examples.mk
...@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) { ...@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
s_http_server_opts.per_directory_auth_file = argv[++i]; s_http_server_opts.per_directory_auth_file = argv[++i];
} else if (strcmp(argv[i], "-r") == 0 && i + 1 < argc) { } else if (strcmp(argv[i], "-r") == 0 && i + 1 < argc) {
s_http_server_opts.url_rewrites = argv[++i]; s_http_server_opts.url_rewrites = argv[++i];
#if !MG_DISABLE_CGI #if MG_ENABLE_HTTP_CGI
} else if (strcmp(argv[i], "-i") == 0 && i + 1 < argc) { } else if (strcmp(argv[i], "-i") == 0 && i + 1 < argc) {
s_http_server_opts.cgi_interpreter = argv[++i]; s_http_server_opts.cgi_interpreter = argv[++i];
#endif #endif
......
This diff is collapsed.
...@@ -1024,7 +1024,7 @@ const char *strerror(); ...@@ -1024,7 +1024,7 @@ const char *strerror();
* WinCE lacks a lot of used in CGI API functions * WinCE lacks a lot of used in CGI API functions
* TODO(alaskin): look for wce_xxxx alternatives * TODO(alaskin): look for wce_xxxx alternatives
*/ */
#define MG_ENABLE_CGI 0 #define MG_ENABLE_HTTP_CGI 0
#endif /* CS_PLATFORM == CS_P_WINCE */ #endif /* CS_PLATFORM == CS_P_WINCE */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_WINCE_H_ */ #endif /* CS_COMMON_PLATFORMS_PLATFORM_WINCE_H_ */
...@@ -1381,18 +1381,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1381,18 +1381,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_HTTP_DIGEST_AUTH 0 #define MG_DISABLE_HTTP_DIGEST_AUTH 0
#endif #endif
#ifndef MG_DISABLE_HTTP
#define MG_DISABLE_HTTP 0
#endif
#ifndef MG_DISABLE_HTTP_KEEP_ALIVE #ifndef MG_DISABLE_HTTP_KEEP_ALIVE
#define MG_DISABLE_HTTP_KEEP_ALIVE 0 #define MG_DISABLE_HTTP_KEEP_ALIVE 0
#endif #endif
#ifndef MG_DISABLE_HTTP_WEBSOCKET
#define MG_DISABLE_HTTP_WEBSOCKET 0
#endif
#ifndef MG_DISABLE_PFS #ifndef MG_DISABLE_PFS
#define MG_DISABLE_PFS 0 #define MG_DISABLE_PFS 0
#endif #endif
...@@ -1413,10 +1405,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1413,10 +1405,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_SOCKETPAIR 0 #define MG_DISABLE_SOCKETPAIR 0
#endif #endif
#ifndef MG_DISABLE_SSI
#define MG_DISABLE_SSI 0
#endif
#ifndef MG_DISABLE_SYNC_RESOLVER #ifndef MG_DISABLE_SYNC_RESOLVER
#define MG_DISABLE_SYNC_RESOLVER 0 #define MG_DISABLE_SYNC_RESOLVER 0
#endif #endif
...@@ -1425,8 +1413,13 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1425,8 +1413,13 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_WS_RANDOM_MASK 0 #define MG_DISABLE_WS_RANDOM_MASK 0
#endif #endif
#ifndef MG_ENABLE_CGI #ifndef MG_ENABLE_HTTP
#define MG_ENABLE_CGI (CS_PLATFORM == CS_P_UNIX || CS_PLATFORM == CS_P_WINDOWS) #define MG_ENABLE_HTTP 1
#endif
#ifndef MG_ENABLE_HTTP_CGI
#define MG_ENABLE_HTTP_CGI \
(CS_PLATFORM == CS_P_UNIX || CS_PLATFORM == CS_P_WINDOWS)
#endif #endif
#ifndef MG_ENABLE_COAP #ifndef MG_ENABLE_COAP
...@@ -1461,6 +1454,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1461,6 +1454,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_HEXDUMP CS_ENABLE_STDIO #define MG_ENABLE_HEXDUMP CS_ENABLE_STDIO
#endif #endif
#ifndef MG_ENABLE_HTTP_SSI
#define MG_ENABLE_HTTP_SSI MG_ENABLE_FILESYSTEM
#endif
#ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART #ifndef MG_ENABLE_HTTP_STREAMING_MULTIPART
#define MG_ENABLE_HTTP_STREAMING_MULTIPART 0 #define MG_ENABLE_HTTP_STREAMING_MULTIPART 0
#endif #endif
...@@ -1469,6 +1466,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); ...@@ -1469,6 +1466,10 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_HTTP_WEBDAV 0 #define MG_ENABLE_HTTP_WEBDAV 0
#endif #endif
#ifndef MG_ENABLE_HTTP_WEBSOCKET
#define MG_ENABLE_HTTP_WEBSOCKET 1
#endif
#ifndef MG_ENABLE_IPV6 #ifndef MG_ENABLE_IPV6
#define MG_ENABLE_IPV6 0 #define MG_ENABLE_IPV6 0
#endif #endif
...@@ -2452,6 +2453,8 @@ int mg_match_prefix_n(const struct mg_str pattern, const struct mg_str str); ...@@ -2452,6 +2453,8 @@ int mg_match_prefix_n(const struct mg_str pattern, const struct mg_str str);
#ifndef CS_MONGOOSE_SRC_HTTP_H_ #ifndef CS_MONGOOSE_SRC_HTTP_H_
#define CS_MONGOOSE_SRC_HTTP_H_ #define CS_MONGOOSE_SRC_HTTP_H_
#if MG_ENABLE_HTTP
/* Amalgamated: #include "mongoose/src/net.h" */ /* Amalgamated: #include "mongoose/src/net.h" */
#ifdef __cplusplus #ifdef __cplusplus
...@@ -2478,22 +2481,10 @@ extern "C" { ...@@ -2478,22 +2481,10 @@ extern "C" {
#define MG_MAX_HTTP_SEND_MBUF 1024 #define MG_MAX_HTTP_SEND_MBUF 1024
#endif #endif
#ifndef MG_WEBSOCKET_PING_INTERVAL_SECONDS
#define MG_WEBSOCKET_PING_INTERVAL_SECONDS 5
#endif
#ifndef MG_CGI_ENVIRONMENT_SIZE #ifndef MG_CGI_ENVIRONMENT_SIZE
#define MG_CGI_ENVIRONMENT_SIZE 8192 #define MG_CGI_ENVIRONMENT_SIZE 8192
#endif #endif
#ifndef MG_MAX_CGI_ENVIR_VARS
#define MG_MAX_CGI_ENVIR_VARS 64
#endif
#ifndef MG_ENV_EXPORT_TO_CGI
#define MG_ENV_EXPORT_TO_CGI "MONGOOSE_CGI"
#endif
/* HTTP message */ /* HTTP message */
struct http_message { struct http_message {
struct mg_str message; /* Whole message: request line + headers + body */ struct mg_str message; /* Whole message: request line + headers + body */
...@@ -2525,12 +2516,14 @@ struct http_message { ...@@ -2525,12 +2516,14 @@ struct http_message {
struct mg_str body; /* Zero-length for requests with no body */ struct mg_str body; /* Zero-length for requests with no body */
}; };
#if MG_ENABLE_HTTP_WEBSOCKET
/* WebSocket message */ /* WebSocket message */
struct websocket_message { struct websocket_message {
unsigned char *data; unsigned char *data;
size_t size; size_t size;
unsigned char flags; unsigned char flags;
}; };
#endif
/* HTTP multipart part */ /* HTTP multipart part */
struct mg_http_multipart_part { struct mg_http_multipart_part {
...@@ -2555,7 +2548,7 @@ struct mg_ssi_call_ctx { ...@@ -2555,7 +2548,7 @@ struct mg_ssi_call_ctx {
#define MG_EV_SSI_CALL 105 /* char * */ #define MG_EV_SSI_CALL 105 /* char * */
#define MG_EV_SSI_CALL_CTX 106 /* struct mg_ssi_call_ctx * */ #define MG_EV_SSI_CALL_CTX 106 /* struct mg_ssi_call_ctx * */
#if !MG_DISABLE_HTTP_WEBSOCKET #if MG_ENABLE_HTTP_WEBSOCKET
#define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST 111 /* NULL */ #define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST 111 /* NULL */
#define MG_EV_WEBSOCKET_HANDSHAKE_DONE 112 /* NULL */ #define MG_EV_WEBSOCKET_HANDSHAKE_DONE 112 /* NULL */
#define MG_EV_WEBSOCKET_FRAME 113 /* struct websocket_message * */ #define MG_EV_WEBSOCKET_FRAME 113 /* struct websocket_message * */
...@@ -2615,7 +2608,7 @@ struct mg_ssi_call_ctx { ...@@ -2615,7 +2608,7 @@ struct mg_ssi_call_ctx {
*/ */
void mg_set_protocol_http_websocket(struct mg_connection *nc); void mg_set_protocol_http_websocket(struct mg_connection *nc);
#if !MG_DISABLE_HTTP_WEBSOCKET #if MG_ENABLE_HTTP_WEBSOCKET
/* /*
* Send websocket handshake to the server. * Send websocket handshake to the server.
* *
...@@ -2721,7 +2714,6 @@ void mg_send_websocket_framev(struct mg_connection *nc, int op_and_flags, ...@@ -2721,7 +2714,6 @@ 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, void mg_printf_websocket_frame(struct mg_connection *nc, int op_and_flags,
const char *fmt, ...); const char *fmt, ...);
#endif /* MG_DISABLE_HTTP_WEBSOCKET */
/* Websocket opcodes, from http://tools.ietf.org/html/rfc6455 */ /* Websocket opcodes, from http://tools.ietf.org/html/rfc6455 */
#define WEBSOCKET_OP_CONTINUE 0 #define WEBSOCKET_OP_CONTINUE 0
...@@ -2745,6 +2737,8 @@ void mg_printf_websocket_frame(struct mg_connection *nc, int op_and_flags, ...@@ -2745,6 +2737,8 @@ void mg_printf_websocket_frame(struct mg_connection *nc, int op_and_flags,
*/ */
#define WEBSOCKET_DONT_FIN 0x100 #define WEBSOCKET_DONT_FIN 0x100
#endif /* MG_ENABLE_HTTP_WEBSOCKET */
/* /*
* Decodes a URL-encoded string. * Decodes a URL-encoded string.
* *
...@@ -2761,6 +2755,9 @@ int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, ...@@ -2761,6 +2755,9 @@ int mg_url_decode(const char *src, int src_len, char *dst, int dst_len,
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* MG_ENABLE_HTTP */
#endif /* CS_MONGOOSE_SRC_HTTP_H_ */ #endif /* CS_MONGOOSE_SRC_HTTP_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "mongoose/src/http_server.h" #line 1 "mongoose/src/http_server.h"
...@@ -2772,6 +2769,8 @@ int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, ...@@ -2772,6 +2769,8 @@ int mg_url_decode(const char *src, int src_len, char *dst, int dst_len,
#ifndef CS_MONGOOSE_SRC_HTTP_SERVER_H_ #ifndef CS_MONGOOSE_SRC_HTTP_SERVER_H_
#define CS_MONGOOSE_SRC_HTTP_SERVER_H_ #define CS_MONGOOSE_SRC_HTTP_SERVER_H_
#if MG_ENABLE_HTTP
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
...@@ -3229,6 +3228,9 @@ void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...); ...@@ -3229,6 +3228,9 @@ void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* MG_ENABLE_HTTP */
#endif /* CS_MONGOOSE_SRC_HTTP_SERVER_H_ */ #endif /* CS_MONGOOSE_SRC_HTTP_SERVER_H_ */
#ifdef MG_MODULE_LINES #ifdef MG_MODULE_LINES
#line 1 "mongoose/src/http_client.h" #line 1 "mongoose/src/http_client.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment