소스 검색

param can from query_string or body

zhen.wang 6 년 전
부모
커밋
80e0929044
1개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. 12 5
      src/CivetServer.cpp

+ 12 - 5
src/CivetServer.cpp

@@ -466,6 +466,7 @@ CivetServer::getParam(struct mg_connection *conn,
                       size_t occurrence)
                       size_t occurrence)
 {
 {
 	const char *formParams = NULL;
 	const char *formParams = NULL;
+	const char *queryString = NULL;
 	const struct mg_request_info *ri = mg_get_request_info(conn);
 	const struct mg_request_info *ri = mg_get_request_info(conn);
 	assert(ri != NULL);
 	assert(ri != NULL);
 	CivetServer *me = (CivetServer *)(ri->user_data);
 	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
 		// get requests do store html <form> field values in the http
 		// query_string
 		// query_string
-		formParams = ri->query_string;
+		queryString = ri->query_string;
 	}
 	}
+
 	mg_unlock_connection(conn);
 	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
 bool