summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2011-09-01 20:21:20 +0100
committerNick White <git@njw.me.uk>2011-09-01 20:21:20 +0100
commit817d2888d7f38dec4e8549def19bd2274ad1f9e7 (patch)
treea8b3b7f5cc1194ce8bac4ffc34659491e9af575b /util.c
parent89c7c8fe61bb7a1b3059e43b96a97d80df2d9835 (diff)
Fix cookie saving, update TODO
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/util.c b/util.c
index 759e25b..6cc0075 100644
--- a/util.c
+++ b/util.c
@@ -72,9 +72,13 @@ int get(char *host, char *path, char *sendcookie, char *savecookie, char **buf)
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 &&
- (t2 = strstr(t, "Set-Cookie: ")) != NULL && sscanf(t2, m, c))
- strncat(savecookie, c, COOKIEMAX);
+ t2 = t;
+ if(savecookie != NULL) {
+ while((t2 = strstr(t2, "Set-Cookie: ")) && sscanf(t2, m, c)) {
+ strncat(savecookie, c, COOKIEMAX);
+ t2++;
+ }
+ }
if((t2 = strstr(t, "\r\n\r\n")) != NULL && (t2 - t) < (signed)res) {
t2+=4;
l = res - (t2 - t);