summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2011-08-21 22:23:12 +0100
committerNick White <git@njw.me.uk>2011-08-21 22:23:12 +0100
commit85750ee58dea89bae829d4d30f41e83d99abc654 (patch)
tree2093b6b28657e92bb86516d41f1335a979cce83c /util.c
parentba96802ba13f022047e93dfa96caddf4fff42146 (diff)
parent6b059ae1888b0cf8d38c7fe9b4f5c10ec28ab7b6 (diff)
Merge work using pages much more efficiently
Diffstat (limited to 'util.c')
-rw-r--r--util.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/util.c b/util.c
index e030be6..04e80b4 100644
--- a/util.c
+++ b/util.c
@@ -56,6 +56,7 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf)
char c[COOKIEMAX] = "";
char t[BUFSIZ];
char *t2;
+ char m[256];
if((fd = dial(host, "80")) == -1) return 0;
@@ -67,10 +68,12 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf)
*buf = NULL;
l = 0;
+ snprintf(m, 256, "Set-Cookie: %%%ds;", COOKIEMAX-1);
while((res = recv(fd, t, BUFSIZ, 0)) > 0) {
if(sscanf(t, "HTTP/%d.%d %d", &i, &i, &p) == 3 && p != 200)
return 0;
- if(savecookie != NULL && sscanf(t, "Set-Cookie: %s;", c))
+ if(savecookie != NULL &&
+ (t2 = strstr(t, "Set-Cookie: ")) != NULL && sscanf(t2, m, c))
strncat(savecookie, c, COOKIEMAX);
if((t2 = strstr(t, "\r\n\r\n")) != NULL) {
t2+=4;