1
0
mirror of https://github.com/lxsang/ant-http synced 2024-06-29 11:59:48 +02:00

fix cookie problem

This commit is contained in:
lxsang 2016-11-23 23:02:10 +01:00
parent e632e29302
commit fc6d64cf7f
5 changed files with 14 additions and 9 deletions

BIN
build/htdocs/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@ -137,11 +137,11 @@ void cat(int client, FILE *resource)
{ {
char buf[1024]; char buf[1024];
fgets(buf, sizeof(buf), resource); //fgets(buf, sizeof(buf), resource);
while (!feof(resource)) while (fgets(buf, sizeof(buf), resource) != NULL)
{ {
send(client, buf, strlen(buf), 0); send(client, buf, strlen(buf), 0);
fgets(buf, sizeof(buf), resource); //fgets(buf, sizeof(buf), resource);
} }

View File

@ -196,17 +196,21 @@ dictionary decode_cookie(const char* line)
{ {
char *token,*token1; char *token,*token1;
char *cpstr = strdup(line); char *cpstr = strdup(line);
trim(cpstr,' ');
trim(cpstr,'\n');
trim(cpstr,'\r');
//printf("FUCKIT %s\n",cpstr );
dictionary dic = NULL; dictionary dic = NULL;
while((token = strsep(&cpstr,";"))) while((token = strsep(&cpstr,";")))
{ {
trim(token,' ');
token1 = strsep(&token,"="); token1 = strsep(&token,"=");
if(token1) if(token1)
{ {
if(dic == NULL) if(dic == NULL)
dic = dict(); dic = dict();
LOG("Found cookie : %s = %s\n",token1,token); //LOG("Found cookie : %s = %s\n",token1,token);
trim(token1,' '); dput(dic,token1,strdup(token));
dput(dic,token1,token);
} }
} }
//} //}

View File

@ -200,12 +200,13 @@ int __f(int client, const char* file)
LOG("Cannot read : %s\n", file); LOG("Cannot read : %s\n", file);
return 0; return 0;
} }
fgets(buf, sizeof(buf), ptr); ;
while(!feof(ptr)) while(fgets(buf, sizeof(buf), ptr) != NULL)
{ {
nbytes = send(client, buf, strlen(buf), 0); nbytes = send(client, buf, strlen(buf), 0);
if(nbytes == -1) return 0; if(nbytes == -1) return 0;
fgets(buf, sizeof(buf), ptr); //LOG("READ : %s\n", buf);
//fgets(buf, sizeof(buf), ptr);
} }
fclose(ptr); fclose(ptr);
return 1; return 1;