int client_con_state = 0;
int chunked = 0;
int is_gzip = 0;
- int is_gzip_header = 1;
+ const char *Err = NULL;
StrBuf *BufHeader = NULL;
StrBuf *Buf;
StrBuf *pBuf = NULL;
- void *SC = NULL;
+ vStreamT *SC = NULL;
IOBuffer ReadBuffer;
IOBuffer WriteBuffer;
if (chunked && !DisableGzip && WCC->Hdr->HR.gzip_ok)
{
is_gzip = 1;
- SC = StrBufNewStreamContext (eZLibEncode);
+ SC = StrBufNewStreamContext (eZLibEncode, &Err);
+ if (SC == NULL) {
+ syslog(LOG_ERR, "Error while initializing stream context: %s", Err);
+ FreeStrBuf(&Buf);
+ return;
+ }
memset(&ReadBuffer, 0, sizeof(IOBuffer));
ReadBuffer.Buf = WCC->WBuf;
}
else
{
- is_gzip_header = 0;
pBuf = WCC->WBuf;
}
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
FreeStrBuf(&BufHeader);
- StrBufDestroyStreamContext(eZLibEncode, SC);
+ if (StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+ syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+ }
return;
}
}
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
FreeStrBuf(&BufHeader);
- StrBufDestroyStreamContext(eZLibEncode, SC);
+ StrBufDestroyStreamContext(eZLibEncode, &SC, &Err);
+ if (StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+ syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+ }
return;
}
int rc;
do {
- rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done);
+ rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done, &Err);
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));
}
}
- StrBufDestroyStreamContext(eZLibEncode, &SC);
+ if (SC && StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+ syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+ }
FreeStrBuf(&WriteBuffer.Buf);
if ((chunked) && (client_con_state == 0))
{