Browse Source

Merge pull request #645 from newle/master

param can from query_string or body
bel2125 6 năm trước cách đây
mục cha
commit
7e496df274
1 tập tin đã thay đổi với 12 bổ sung5 xóa
  1. 12 5
      src/CivetServer.cpp

+ 12 - 5
src/CivetServer.cpp

@@ -466,6 +466,7 @@ CivetServer::getParam(struct mg_connection *conn,
                       size_t occurrence)
 {
 	const char *formParams = NULL;
+	const char *queryString = NULL;
 	const struct mg_request_info *ri = mg_get_request_info(conn);
 	assert(ri != NULL);
 	CivetServer *me = (CivetServer *)(ri->user_data);
@@ -511,18 +512,24 @@ CivetServer::getParam(struct mg_connection *conn,
 			}
 		}
 	}
-	if (formParams == NULL) {
+
+	if (ri->query_string != NULL) {
 		// get requests do store html <form> field values in the http
 		// query_string
-		formParams = ri->query_string;
+		queryString = ri->query_string;
 	}
+
 	mg_unlock_connection(conn);
 
-	if (formParams != NULL) {
-		return getParam(formParams, strlen(formParams), name, dst, occurrence);
+	bool get_param_success = false;
+	if (!get_param_success && formParams != NULL) {
+		get_param_success = getParam(formParams, strlen(formParams), name, dst, occurrence);
+	}
+	if (!get_param_success && queryString != NULL) {
+		get_param_success = getParam(queryString, strlen(formParams), name, dst, occurrence);
 	}
 
-	return false;
+	return get_param_success;
 }
 
 bool