Its the job of the stream lib to suppress chunks just consisting of the gzip header.
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 20 Jan 2015 21:11:12 +0000 (22:11 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 20 Jan 2015 21:11:12 +0000 (22:11 +0100)
libcitadel/lib/stringbuf.c
webcit/tcp_sockets.c

index 5cbe17f..97260c4 100644 (file)
@@ -3025,7 +3025,7 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
        case eZLibEncode:
        {
                z_enc_stream *stream = (z_enc_stream *)vStream;
-               int org_outbuf_len = stream->zstream.total_out;
+               int org_outbuf_len = stream->OutBuf.BufUsed;
                int err;
                unsigned int chunkavail;
 
@@ -3047,9 +3047,14 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
                err = deflate(&stream->zstream,  (LastChunk) ? Z_FINISH : Z_NO_FLUSH);
 
                stream->OutBuf.BufUsed += (chunkavail - stream->zstream.avail_out);
-               /// todo + org_outbuf_len;
 
-               if (Target) SwapBuffers(Target->Buf, &stream->OutBuf);
+               if (Target && 
+                   (LastChunk ||
+                    (stream->OutBuf.BufUsed != org_outbuf_len)
+                           ))
+               {
+                       SwapBuffers(Target->Buf, &stream->OutBuf);
+               }
 
                if (stream->zstream.avail_in == 0)
                {
@@ -3075,7 +3080,7 @@ int StrBufStreamTranscode(eStreamType type, IOBuffer *Target, IOBuffer *In, cons
                        }
                }
                return (LastChunk && (err != Z_FINISH));
-
+               
        }
        break;
        case eZLibDecode: {
index 19fb7a2..33889f6 100644 (file)
@@ -556,7 +556,6 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        int client_con_state = 0;
        int chunked = 0;
        int is_gzip = 0;
-       int is_gzip_header = 1;
        StrBuf *BufHeader = NULL;
        StrBuf *Buf;
        StrBuf *pBuf = NULL;
@@ -624,7 +623,6 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        }
        else
        {
-               is_gzip_header = 0;
                pBuf = WCC->WBuf;
        }
 
@@ -689,11 +687,6 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                                        rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done);
 
                                        if (StrLength (pBuf) > 0) {
-                                               if (!done && is_gzip_header && (StrLength(pBuf) == 10)) {
-                                                       /* we don't want to send the gzip header as single package... */
-                                                       break;
-                                               }
-                                               is_gzip_header = 0;
                                                StrBufPrintf(BufHeader, "%s%x\r\n", 
                                                     (first)?"":"\r\n",
                                                             StrLength (pBuf));