X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fwebcit.c;h=d4d9cacc41f01bc46355aebc550ebc4298015749;hb=42d25facbd8e3dbaeda448095c5761768195df03;hp=46623d1dafbd7630d76ee4b42e553011f4631808;hpb=d7122d9b8ae8863ca4412deb95b619585f28eda6;p=citadel.git diff --git a/webcit/webcit.c b/webcit/webcit.c index 46623d1da..d4d9cacc4 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -152,6 +152,31 @@ char *bstr(char *key) } +#ifdef WITH_ZLIB + +ssize_t http_write(int fd, const void *buf, size_t count) { + + if (WC->gzfd) { + return gzwrite(WC->gzfd, buf, count); + } + else { + return write(fd, buf, count); + } + + +} + +#else + +ssize_t http_write(int fd, const void *buf, size_t count) { + return write(fd, buf, count); +} + +#endif + + + + void wprintf(const char *format,...) { va_list arg_ptr; @@ -161,7 +186,7 @@ void wprintf(const char *format,...) vsprintf(wbuf, format, arg_ptr); va_end(arg_ptr); - write(WC->http_sock, wbuf, strlen(wbuf)); + http_write(WC->http_sock, wbuf, strlen(wbuf)); } @@ -295,6 +320,9 @@ void output_headers(int controlcode) int suppress_check = 0; char httpnow[SIZ]; static int pageseq = 0; +#ifdef WITH_ZLIB + gzFile temp_gzfd = NULL; +#endif print_standard_html_head = controlcode & 0x03; refresh30 = ((controlcode & 0x04) >> 2); @@ -304,12 +332,23 @@ void output_headers(int controlcode) httpdate(httpnow, time(NULL)); +#ifdef WITH_ZLIB + if (WC->gzcompressed) { + temp_gzfd = gzdopen(WC->http_sock, "wb9"); + } +#endif + if (print_standard_html_head > 0) { wprintf("Content-type: text/html\n"); wprintf("Server: %s\n", SERVER); wprintf("Connection: close\n"); wprintf("Pragma: no-cache\n"); wprintf("Cache-Control: no-store\n"); +#ifdef WITH_ZLIB + if (temp_gzfd != NULL) { + wprintf("Content-Encoding: gzip\n"); + } +#endif } stuff_to_cookie(cookie, WC->wc_session, WC->wc_username, WC->wc_password, WC->wc_roomname); @@ -324,6 +363,13 @@ void output_headers(int controlcode) if (print_standard_html_head > 0) { wprintf("\n"); + +#ifdef WITH_ZLIB + if (temp_gzfd != NULL) { + WC->gzfd = temp_gzfd; + } +#endif + wprintf("