mirror of
				https://github.com/lxsang/ant-http
				synced 2025-10-31 10:25:55 +01:00 
			
		
		
		
	clean code
This commit is contained in:
		| @@ -119,7 +119,7 @@ void rule_check(association it, const char* host, const char* _url, const char* | |||||||
| 	int idx = 0; | 	int idx = 0; | ||||||
| 	memset(rep,0,10); | 	memset(rep,0,10); | ||||||
| 	// 1 group | 	// 1 group | ||||||
| 	if( !(ret = regex_match(it->key,host, 10, key_matches)) ) | 	if(!host ||  !(ret = regex_match(it->key,host, 10, key_matches)) ) | ||||||
| 	{ | 	{ | ||||||
| 		target = url; | 		target = url; | ||||||
| 		ret = regex_match(it->key,url, 10, key_matches); | 		ret = regex_match(it->key,url, 10, key_matches); | ||||||
| @@ -439,6 +439,7 @@ dictionary decode_request(int client,const char* method, char* url) | |||||||
| 	char * token; | 	char * token; | ||||||
| 	char* query = NULL; | 	char* query = NULL; | ||||||
| 	char* ctype = NULL; | 	char* ctype = NULL; | ||||||
|  | 	char* host = NULL; | ||||||
| 	int clen = -1; | 	int clen = -1; | ||||||
| 	// first real all header | 	// first real all header | ||||||
| // this for check if web socket is enabled | // this for check if web socket is enabled | ||||||
| @@ -458,11 +459,11 @@ dictionary decode_request(int client,const char* method, char* url) | |||||||
| 		} | 		} | ||||||
| 		else if(token != NULL &&strcasecmp(token,"Content-Type") == 0) | 		else if(token != NULL &&strcasecmp(token,"Content-Type") == 0) | ||||||
| 		{ | 		{ | ||||||
| 			ctype = strsep(&line,":"); | 			ctype = line; //strsep(&line,":"); | ||||||
| 			trim(ctype,' '); | 			trim(ctype,' '); | ||||||
| 		} else if(token != NULL &&strcasecmp(token,"Content-Length") == 0) | 		} else if(token != NULL &&strcasecmp(token,"Content-Length") == 0) | ||||||
| 		{ | 		{ | ||||||
| 			token = strsep(&line,":"); | 			token = line; //strsep(&line,":"); | ||||||
| 			trim(token,' '); | 			trim(token,' '); | ||||||
| 			clen = atoi(token); | 			clen = atoi(token); | ||||||
| 		} | 		} | ||||||
| @@ -474,7 +475,7 @@ dictionary decode_request(int client,const char* method, char* url) | |||||||
| 				ws = 1; | 				ws = 1; | ||||||
| 		}else if(token != NULL && strcasecmp(token,"Host") == 0) | 		}else if(token != NULL && strcasecmp(token,"Host") == 0) | ||||||
| 		{ | 		{ | ||||||
| 			query = apply_rules(line, url); | 			host = line; | ||||||
| 		} | 		} | ||||||
| 			else if(token != NULL && strcasecmp(token,"Sec-WebSocket-Key") == 0) | 			else if(token != NULL && strcasecmp(token,"Sec-WebSocket-Key") == 0) | ||||||
| 		{ | 		{ | ||||||
| @@ -487,6 +488,7 @@ dictionary decode_request(int client,const char* method, char* url) | |||||||
|  |  | ||||||
| 	if(strcmp(method,"GET") == 0) | 	if(strcmp(method,"GET") == 0) | ||||||
| 	{  | 	{  | ||||||
|  | 		query = apply_rules(host, url); | ||||||
| 		if(query) | 		if(query) | ||||||
| 		{ | 		{ | ||||||
| 			request = decode_url_request(query); | 			request = decode_url_request(query); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user