}
+#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;
vsprintf(wbuf, format, arg_ptr);
va_end(arg_ptr);
- write(WC->http_sock, wbuf, strlen(wbuf));
+ http_write(WC->http_sock, wbuf, strlen(wbuf));
}
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);
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);
if (print_standard_html_head > 0) {
wprintf("\n");
+
+#ifdef WITH_ZLIB
+ if (temp_gzfd != NULL) {
+ WC->gzfd = temp_gzfd;
+ }
+#endif
+
wprintf("<HTML><HEAD><TITLE>");
escputs(serv_info.serv_humannode);
wprintf("</TITLE>\n"
bigbuffer = malloc(bytes);
fread(bigbuffer, bytes, 1, fp);
fclose(fp);
- write(WC->http_sock, bigbuffer, bytes);
+ http_write(WC->http_sock, bigbuffer, bytes);
free(bigbuffer);
}
if (!strcasecmp(bstr("force_close_session"), "yes")) {
else {
memset(xferbuf, 0, thisblock);
}
- write(WC->http_sock, xferbuf, thisblock);
+ http_write(WC->http_sock, xferbuf, thisblock);
bytes = bytes - thisblock;
accomplished = accomplished + thisblock;
}
else {
memset(xferbuf, 0, thisblock);
}
- write(WC->http_sock, xferbuf, thisblock);
+ http_write(WC->http_sock, xferbuf, thisblock);
bytes = bytes - thisblock;
accomplished = accomplished + thisblock;
}
WC->is_wap = 0;
+ if (gzip) {
+ WC->gzcompressed = 1;
+ }
+ else {
+ WC->gzcompressed = 0;
+ }
+
hptr = req;
if (hptr == NULL) return;
free(WC->upload);
WC->upload_length = 0;
}
+
+#ifdef WITH_ZLIB
+ if (WC->gzfd) {
+ gzclose(WC->gzfd);
+ WC->gzfd = NULL;
+ WC->gzcompressed = 0;
+ }
+#endif
}
/* $Id$ */
+#ifdef WITH_ZLIB
+#include <zlib.h>
+#endif
+
#define SIZ 4096 /* generic buffer size */
#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
char this_page[SIZ]; /* address of current page */
char http_host[SIZ]; /* HTTP Host: header */
char *preferences;
+#ifdef WITH_ZLIB
+ int gzcompressed; /* nonzero if compressed output */
+ gzFile gzfd; /* stream to send compressed */
+#endif
};
#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|')
void do_listsub(void);
void toggle_self_service(void);
void summary(void);
+ssize_t write(int fd, const void *buf, size_t count);