mirror of
https://github.com/lxsang/ant-http
synced 2024-11-19 09:48:22 +01:00
clean code
This commit is contained in:
parent
08e3e118c4
commit
8cb088e254
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user