|
@@ -1905,6 +1905,7 @@ enum {
|
|
#if defined(USE_LUA)
|
|
#if defined(USE_LUA)
|
|
LUA_BACKGROUND_SCRIPT,
|
|
LUA_BACKGROUND_SCRIPT,
|
|
#endif
|
|
#endif
|
|
|
|
+ ADDITIONAL_HEADER,
|
|
|
|
|
|
NUM_OPTIONS
|
|
NUM_OPTIONS
|
|
};
|
|
};
|
|
@@ -1998,17 +1999,21 @@ static struct mg_option config_options[] = {
|
|
#if defined(USE_LUA)
|
|
#if defined(USE_LUA)
|
|
{"lua_background_script", CONFIG_TYPE_FILE, NULL},
|
|
{"lua_background_script", CONFIG_TYPE_FILE, NULL},
|
|
#endif
|
|
#endif
|
|
|
|
+ {"additional_header", CONFIG_TYPE_STRING, NULL},
|
|
|
|
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
{NULL, CONFIG_TYPE_UNKNOWN, NULL}};
|
|
|
|
|
|
|
|
+
|
|
/* Check if the config_options and the corresponding enum have compatible
|
|
/* Check if the config_options and the corresponding enum have compatible
|
|
* sizes. */
|
|
* sizes. */
|
|
mg_static_assert((sizeof(config_options) / sizeof(config_options[0]))
|
|
mg_static_assert((sizeof(config_options) / sizeof(config_options[0]))
|
|
== (NUM_OPTIONS + 1),
|
|
== (NUM_OPTIONS + 1),
|
|
"config_options and enum not sync");
|
|
"config_options and enum not sync");
|
|
|
|
|
|
|
|
+
|
|
enum { REQUEST_HANDLER, WEBSOCKET_HANDLER, AUTH_HANDLER };
|
|
enum { REQUEST_HANDLER, WEBSOCKET_HANDLER, AUTH_HANDLER };
|
|
|
|
|
|
|
|
+
|
|
struct mg_handler_info {
|
|
struct mg_handler_info {
|
|
/* Name/Pattern of the URI. */
|
|
/* Name/Pattern of the URI. */
|
|
char *uri;
|
|
char *uri;
|
|
@@ -2039,6 +2044,7 @@ struct mg_handler_info {
|
|
struct mg_handler_info *next;
|
|
struct mg_handler_info *next;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
struct mg_context {
|
|
struct mg_context {
|
|
volatile int stop_flag; /* Should we stop event loop */
|
|
volatile int stop_flag; /* Should we stop event loop */
|
|
SSL_CTX *ssl_ctx; /* SSL context */
|
|
SSL_CTX *ssl_ctx; /* SSL context */
|
|
@@ -3420,6 +3426,7 @@ static int
|
|
send_additional_header(struct mg_connection *conn)
|
|
send_additional_header(struct mg_connection *conn)
|
|
{
|
|
{
|
|
int i = 0;
|
|
int i = 0;
|
|
|
|
+ const char *header = conn->ctx->config[ADDITIONAL_HEADER];
|
|
|
|
|
|
#if !defined(NO_SSL)
|
|
#if !defined(NO_SSL)
|
|
if (conn->ctx->config[STRICT_HTTPS_MAX_AGE]) {
|
|
if (conn->ctx->config[STRICT_HTTPS_MAX_AGE]) {
|
|
@@ -3430,10 +3437,12 @@ send_additional_header(struct mg_connection *conn)
|
|
(unsigned)max_age);
|
|
(unsigned)max_age);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-#else
|
|
|
|
- (void)conn; /* unused */
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+ if (header && header[0]) {
|
|
|
|
+ i += mg_printf(conn, "%s\r\n", header);
|
|
|
|
+ }
|
|
|
|
+
|
|
return i;
|
|
return i;
|
|
}
|
|
}
|
|
|
|
|