Browse Source

Set MG_LEGACY_INTERFACE define for deprecated member "uri"

bel 8 years ago
parent
commit
97406d100d
2 changed files with 17 additions and 7 deletions
  1. 9 7
      include/civetweb.h
  2. 8 0
      src/civetweb.c

+ 9 - 7
include/civetweb.h

@@ -83,13 +83,15 @@ struct mg_request_info {
 	const char *local_uri;      /* URL-decoded URI (relative). Can be NULL
 	                             * if the request_uri does not address a
 	                             * resource at the server host. */
-	const char *uri;            /* Deprecated: use local_uri instead */
-	const char *http_version;   /* E.g. "1.0", "1.1" */
-	const char *query_string;   /* URL part after '?', not including '?', or
-	                               NULL */
-	const char *remote_user;    /* Authenticated user, or NULL if no auth
-	                               used */
-	char remote_addr[48];       /* Client's IP address as a string. */
+#if defined(MG_LEGACY_INTERFACE)
+	const char *uri; /* Deprecated: use local_uri instead */
+#endif
+	const char *http_version; /* E.g. "1.0", "1.1" */
+	const char *query_string; /* URL part after '?', not including '?', or
+	                             NULL */
+	const char *remote_user;  /* Authenticated user, or NULL if no auth
+	                             used */
+	char remote_addr[48];     /* Client's IP address as a string. */
 
 #if defined(MG_LEGACY_INTERFACE)
 	long remote_ip; /* Client's IP address. Deprecated: use remote_addr instead

+ 8 - 0
src/civetweb.c

@@ -12688,8 +12688,10 @@ reset_per_request_attributes(struct mg_connection *conn)
 	conn->request_info.request_method = NULL;
 	conn->request_info.request_uri = NULL;
 	conn->request_info.local_uri = NULL;
+#if defined(MG_LEGACY_INTERFACE)
 	conn->request_info.uri = NULL; /* TODO: cleanup uri,
 	                                * local_uri and request_uri */
+#endif
 	conn->request_info.http_version = NULL;
 	conn->request_info.num_headers = 0;
 	conn->data_len = 0;
@@ -13507,9 +13509,11 @@ mg_get_response(struct mg_connection *conn,
 		ret = getreq(conn, ebuf, ebuf_len, &err);
 		conn->ctx = octx;
 
+#if defined(MG_LEGACY_INTERFACE)
 		/* TODO: 1) uri is deprecated;
 		 *       2) here, ri.uri is the http response code */
 		conn->request_info.uri = conn->request_info.request_uri;
+#endif
 
 		/* TODO (mid): Define proper return values - maybe return length?
 		 * For the first test use <0 for error and >0 for OK */
@@ -13551,9 +13555,11 @@ mg_download(const char *host,
 		} else {
 			getreq(conn, ebuf, ebuf_len, &reqerr);
 
+#if defined(MG_LEGACY_INTERFACE)
 			/* TODO: 1) uri is deprecated;
 			 *       2) here, ri.uri is the http response code */
 			conn->request_info.uri = conn->request_info.request_uri;
+#endif
 		}
 	}
 
@@ -13815,8 +13821,10 @@ process_new_connection(struct mg_connection *conn)
 					break;
 				}
 
+#if defined(MG_LEGACY_INTERFACE)
 				/* TODO: cleanup uri, local_uri and request_uri */
 				conn->request_info.uri = conn->request_info.local_uri;
+#endif
 			}
 
 			DEBUG_TRACE("http: %s, error: %s",