* when reading SSL buffers, measure existing buffer content the same way as with...
authorWilfried Göesgens <willi@citadel.org>
Thu, 25 Sep 2008 22:14:36 +0000 (22:14 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 25 Sep 2008 22:14:36 +0000 (22:14 +0000)
webcit/webserver.c

index d8bd340055ace45cb0d077c96e35b3561254b2a3..bb140bc65421f8f442b3ef08fa3347ecf6f854dd 100644 (file)
@@ -202,12 +202,18 @@ int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeou
        int retval = 0;
 
 #ifdef HAVE_OPENSSL
-       if (is_https) {
-               while ((retval >= 0) && (StrLength(Buf) < bytes))
+       if (is_https) {//// TODO: loop; count till bytes is reached
+               bytes -= StrLength(Target);
+               while ((retval >= 0) && (StrLength(Buf) - StrLength(Target) < bytes))
                        retval = client_read_sslbuffer(Buf, timeout);
                if (retval >= 0) {
                        StrBufAppendBuf(Target, Buf, 0); /// todo: Buf > bytes?
-
+#ifdef HTTP_TRACING
+                       write(2, "\033[32m", 5);
+                       write(2, buf, bytes);
+                       write(2, "\033[30m", 5);
+#endif
+                       return 1;
                }
                else {
                        lprintf(2, "client_read_ssl() failed\n");
@@ -235,7 +241,7 @@ int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeou
        write(2, buf, bytes);
        write(2, "\033[30m", 5);
 #endif
-       return (1);
+       return 1;
 }