mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 16:58:22 +01:00
fix cookie error on POST message
This commit is contained in:
parent
5ebe581ea3
commit
355bda010d
@ -39,22 +39,26 @@ dictionary decode_request(int client,const char* method,const char* query)
|
||||
dictionary request = NULL;
|
||||
dictionary cookie = NULL;
|
||||
char* line;
|
||||
char * token;
|
||||
if(strcmp(method,"GET") == 0)
|
||||
{
|
||||
while((line = read_line(client)) && strcmp("\r\n",line))
|
||||
{
|
||||
token = strsep(&line,":");
|
||||
trim(token,' ');
|
||||
if(token != NULL &&strcasecmp(token,"Cookie") == 0)
|
||||
if(!cookie) cookie = decode_cookie(line);
|
||||
}
|
||||
request = decode_url_request(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
char * token;
|
||||
char* ctype = NULL;
|
||||
int clen = -1;
|
||||
line = read_line(client);
|
||||
while ((strlen(line) > 0) && strcmp("\r\n",line))
|
||||
while (line && strcmp("\r\n",line))
|
||||
{
|
||||
//printf("%s\n",line);
|
||||
token = strsep(&line,":");
|
||||
trim(token,' ');
|
||||
if(token != NULL &&strcasecmp(token,"Content-Type") == 0)
|
||||
@ -69,7 +73,7 @@ dictionary decode_request(int client,const char* method,const char* query)
|
||||
trim(token,' ');
|
||||
clen = atoi(token);
|
||||
}
|
||||
else
|
||||
else if(token != NULL &&strcasecmp(token,"Cookie") == 0)
|
||||
{
|
||||
if(!cookie) cookie = decode_cookie(line);
|
||||
}
|
||||
@ -128,10 +132,6 @@ dictionary decode_cookie(const char* line)
|
||||
char *token,*token1;
|
||||
char *cpstr = strdup(line);
|
||||
dictionary dic = NULL;
|
||||
token = strsep(&cpstr,":");
|
||||
trim(token,' ');
|
||||
if(token != NULL &&strcasecmp(token,"Cookie") == 0)
|
||||
{
|
||||
while((token = strsep(&cpstr,";")))
|
||||
{
|
||||
token1 = strsep(&token,"=");
|
||||
@ -143,7 +143,7 @@ dictionary decode_cookie(const char* line)
|
||||
dput(dic,token1,token);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
return dic;
|
||||
//free(cpstr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user