浏览代码

Add new feature defines

bel2125 4 年之前
父节点
当前提交
78aac66ed3
共有 5 个文件被更改,包括 33 次插入21 次删除
  1. 7 2
      include/civetweb.h
  2. 12 12
      src/civetweb.c
  3. 7 0
      src/mod_lua.inl
  4. 1 1
      src/third_party/civetweb_lua.h
  5. 6 6
      unittest/public_server.c

+ 7 - 2
include/civetweb.h

@@ -98,8 +98,13 @@ enum {
 	/* Will only work, if USE_ZLIB is set. */
 	MG_FEATURES_COMPRESSION = 0x200u,
 
-	/* Collect server status information. */
-	/* Will only work, if USE_SERVER_STATS is set. */
+	/* HTTP/2 support enabled. */
+	MG_FEATURES_HTTP2 = 0x400u,
+
+	/* Support unix domain sockets. */
+	MG_FEATURES_X_DOMAIN_SOCKET = 0x800u,
+
+	/* Bit mask for all feature defines. */
 	MG_FEATURES_ALL = 0xFFFFu
 };
 

+ 12 - 12
src/civetweb.c

@@ -20598,26 +20598,26 @@ mg_check_feature(unsigned feature)
 #if defined(USE_ZLIB)
 	                                    | MG_FEATURES_COMPRESSION
 #endif
+#if defined(USE_HTTP2)
+	                                    | MG_FEATURES_HTTP2
+#endif
+#if defined(USE_X_DOM_SOCKET)
+	                                    | MG_FEATURES_X_DOMAIN_SOCKET
+#endif
 
 /* Set some extra bits not defined in the API documentation.
  * These bits may change without further notice. */
 #if defined(MG_LEGACY_INTERFACE)
-	                                    | 0x00008000u
+	                                    | 0x80000000u
 #endif
 #if defined(MG_EXPERIMENTAL_INTERFACES)
-	                                    | 0x00004000u
+	                                    | 0x40000000u
 #endif
-#if defined(MEMORY_DEBUGGING)
-	                                    | 0x00001000u
+#if !defined(NO_RESPONSE_BUFFERING)
+	                                    | 0x20000000u
 #endif
-#if defined(USE_TIMERS)
-	                                    | 0x00020000u
-#endif
-#if !defined(NO_NONCE_CHECK)
-	                                    | 0x00040000u
-#endif
-#if !defined(NO_POPEN)
-	                                    | 0x00080000u
+#if defined(MEMORY_DEBUGGING)
+	                                    | 0x10000000u
 #endif
 	    ;
 	return (feature & feature_set);

+ 7 - 0
src/mod_lua.inl

@@ -2444,6 +2444,13 @@ prepare_lua_request_info(struct mg_connection *conn, lua_State *L)
 		reg_string(L, "path_info", conn->path_info);
 	}
 
+	{
+		char buf[2048];
+		if (0 == mg_get_request_link(conn, buf, sizeof(buf))) {
+			reg_string(L, "request_link", buf);
+		}
+	}
+
 	if (conn->request_info.content_length >= 0) {
 		/* reg_int64: content_length */
 		lua_pushstring(L, "content_length");

+ 1 - 1
src/third_party/civetweb_lua.h

@@ -73,7 +73,7 @@
 
 #endif
 
-#ifdef LUA_VERSION_MAKEFILE
+#if defined(LUA_VERSION_MAKEFILE)
 #if LUA_VERSION_MAKEFILE != LUA_VERSION_NUM
 #error                                                                         \
     "Mismatch between Lua version specified in Makefile and Lua version in lua.h"

+ 6 - 6
unittest/public_server.c

@@ -979,7 +979,7 @@ request_test_handler2(struct mg_connection *conn, void *cbdata)
 }
 
 
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 /****************************************************************************/
 /* WEBSOCKET SERVER                                                         */
 /****************************************************************************/
@@ -1387,7 +1387,7 @@ START_TEST(test_request_handlers)
 	        ipv4_port);
 	mg_set_request_handler(ctx, "/handler2", request_test_handler2, NULL);
 
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 	mg_set_websocket_handler(ctx,
 	                         "/websocket",
 	                         websock_server_connect,
@@ -1980,7 +1980,7 @@ START_TEST(test_request_handlers)
 
 
 /* Websocket test */
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 	/* Then connect a first client */
 	ws_client1_conn =
 	    mg_connect_websocket_client("localhost",
@@ -2031,7 +2031,7 @@ START_TEST(test_request_handlers)
 	ws_client1_data.len = 0;
 
 /* Now connect a second client */
-#ifdef USE_IPV6
+#if defined(USE_IPV6)
 	ws_client2_conn =
 	    mg_connect_websocket_client("[::1]",
 	                                ipv6_port,
@@ -2276,7 +2276,7 @@ START_TEST(test_request_handlers)
 	test_mg_stop(ctx, __LINE__);
 	mark_point();
 
-#ifdef USE_WEBSOCKET
+#if defined(USE_WEBSOCKET)
 	for (i = 0; i < 100; i++) {
 		test_sleep(1);
 		if (ws_client3_data.closed != 0) {
@@ -3698,7 +3698,7 @@ START_TEST(test_error_handling)
 	ck_assert_str_eq(errmsg, "Invalid number of worker threads");
 
 /* Set to a number - but use a number above the limit */
-#ifdef MAX_WORKER_THREADS
+#if defined(MAX_WORKER_THREADS)
 	sprintf(bad_thread_num, "%u", MAX_WORKER_THREADS + 1);
 #else
 	sprintf(bad_thread_num, "%lu", 1000000000lu);