summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO4
-rwxr-xr-x[-rw-r--r--]gui.tcl0
-rw-r--r--util.c10
3 files changed, 10 insertions, 4 deletions
diff --git a/TODO b/TODO
index 8bd702f..0da61ee 100644
--- a/TODO
+++ b/TODO
@@ -17,7 +17,9 @@ use wide string functions when dealing with stuff returned over http; it's known
bug in get(): if the \r\n\r\n after http headers is cut off between recv buffers
-create a tcl/tk gui wrapper, which asks for the book downloader to run, the book id, and then shows output of stdout & stderr as it runs
+what happens if we receive not a http header? does recv loop forever, in a memory killing manner?
+
+print stderr in gui as well
package for osx and windows
diff --git a/gui.tcl b/gui.tcl
index 08d3f04..08d3f04 100644..100755
--- a/gui.tcl
+++ b/gui.tcl
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);