Explorar el Código

Mark open_file as candidate for deletion

Allow MG_USE_OPEN_FILE to reactivate it for the moment.

Everybody who needs this feature, please contribute to the discussion at
https://groups.google.com/forum/#!topic/civetweb/h9HT4CmeYqI
until end of April 2017.
bel hace 8 años
padre
commit
cb3ac4c566
Se han modificado 2 ficheros con 15 adiciones y 0 borrados
  1. 13 0
      include/civetweb.h
  2. 2 0
      src/civetweb.c

+ 13 - 0
include/civetweb.h

@@ -201,6 +201,18 @@ struct mg_callbacks {
 	   mg_set_websocket_handler instead. */
 	void (*connection_close)(const struct mg_connection *);
 
+#if defined(MG_USE_OPEN_FILE)
+	/* Note: The "file in memory" feature is a deletion candidate, since
+	 * it complicates the code, and does not add any value compared to
+	 * "mg_add_request_handler".
+	 * See this discussion thread:
+	 * https://groups.google.com/forum/#!topic/civetweb/h9HT4CmeYqI
+	 * If you disagree, if there is any situation this is indeed useful
+	 * and cannot trivially be replaced by another existing feature,
+	 * please contribute to this discussion during the next 3 month
+	 * (till end of April 2017), otherwise this feature might be dropped
+	 * in future releases. */
+
 	/* Called when civetweb tries to open a file. Used to intercept file open
 	   calls, and serve file data from memory instead.
 	   Parameters:
@@ -214,6 +226,7 @@ struct mg_callbacks {
 	const char *(*open_file)(const struct mg_connection *,
 	                         const char *path,
 	                         size_t *data_len);
+#endif
 
 	/* Called when civetweb is about to serve Lua server page, if
 	   Lua support is enabled.

+ 2 - 0
src/civetweb.c

@@ -2264,6 +2264,7 @@ open_file_in_memory(const struct mg_connection *conn,
 		return 0;
 	}
 
+#if defined(MG_USE_OPEN_FILE)
 	if (conn->ctx->callbacks.open_file) {
 		buf = conn->ctx->callbacks.open_file(conn, path, &size);
 		if (buf != NULL) {
@@ -2290,6 +2291,7 @@ open_file_in_memory(const struct mg_connection *conn,
 			filep->stat.is_gzipped = 0;
 		}
 	}
+#endif
 
 	return (buf != NULL);
 }