projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d7122d9
)
* Finished gzip compression of dynamic pages (when browser supports it)
author
Art Cancro
<ajc@citadel.org>
Sat, 14 Sep 2002 04:02:36 +0000
(
04:02
+0000)
committer
Art Cancro
<ajc@citadel.org>
Sat, 14 Sep 2002 04:02:36 +0000
(
04:02
+0000)
webcit/ChangeLog
patch
|
blob
|
history
webcit/context_loop.c
patch
|
blob
|
history
webcit/floors.c
patch
|
blob
|
history
webcit/html2html.c
patch
|
blob
|
history
webcit/webcit.c
patch
|
blob
|
history
webcit/webcit.h
patch
|
blob
|
history
diff --git
a/webcit/ChangeLog
b/webcit/ChangeLog
index f5efca2168e0826d0ef009f0b6d7d9350a49897e..8b03cdbcd8ff5d1a5cf533baf172bc39df1e4101 100644
(file)
--- a/
webcit/ChangeLog
+++ b/
webcit/ChangeLog
@@
-1,4
+1,7
@@
$Log$
$Log$
+Revision 400.4 2002/09/14 04:02:36 ajc
+* Finished gzip compression of dynamic pages (when browser supports it)
+
Revision 400.3 2002/09/13 20:40:53 ajc
* Detect when the client browser is capable of gzip encoding
(actual encoding is not implemented yet)
Revision 400.3 2002/09/13 20:40:53 ajc
* Detect when the client browser is capable of gzip encoding
(actual encoding is not implemented yet)
@@
-947,4
+950,3
@@
Sun Dec 6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
diff --git
a/webcit/context_loop.c
b/webcit/context_loop.c
index 9b744f13f12708675abade12df20fa94ff8f489d..3a9a29178d9dc1fdc604139a72d738c889fdeb5e 100644
(file)
--- a/
webcit/context_loop.c
+++ b/
webcit/context_loop.c
@@
-35,11
+35,6
@@
#include <stdarg.h>
#include <pthread.h>
#include <signal.h>
#include <stdarg.h>
#include <pthread.h>
#include <signal.h>
-
-#ifdef WITH_ZLIB
-#include <zlib.h>
-#endif
-
#include "webcit.h"
#include "webserver.h"
#include "webcit.h"
#include "webserver.h"
@@
-255,6
+250,7
@@
void context_loop(int sock)
got_cookie = 1;
}
got_cookie = 1;
}
+#ifdef WITH_ZLIB
if (!strncasecmp(buf, "Accept-encoding: ", 17)) {
extract_token(encodings, &buf[17], 0, ';');
for (i=0; i<num_tokens(encodings, ','); ++i) {
if (!strncasecmp(buf, "Accept-encoding: ", 17)) {
extract_token(encodings, &buf[17], 0, ';');
for (i=0; i<num_tokens(encodings, ','); ++i) {
@@
-264,6
+260,7
@@
void context_loop(int sock)
}
}
}
}
}
}
+#endif
hptr = (struct httprequest *)
malloc(sizeof(struct httprequest));
hptr = (struct httprequest *)
malloc(sizeof(struct httprequest));
diff --git
a/webcit/floors.c
b/webcit/floors.c
index 48cca50f51fd88a7cf00154a4594b52871eccfc5..511a5907ea7c6281153a6acc9687c8572a7db4e2 100644
(file)
--- a/
webcit/floors.c
+++ b/
webcit/floors.c
@@
-43,7
+43,7
@@
void display_floorconfig(char *prepend_html)
output_headers(3);
if (prepend_html != NULL) {
output_headers(3);
if (prepend_html != NULL) {
- write(WC->http_sock, prepend_html, strlen(prepend_html));
+
http_
write(WC->http_sock, prepend_html, strlen(prepend_html));
}
serv_printf("LFLR"); /* FIXME put a real test here */
}
serv_printf("LFLR"); /* FIXME put a real test here */
diff --git
a/webcit/html2html.c
b/webcit/html2html.c
index 023ab7c4af8184dfc9193003d28079a8d3964f38..a0a976ffc3d58cf776af23fbd93f2bcd787afe32 100644
(file)
--- a/
webcit/html2html.c
+++ b/
webcit/html2html.c
@@
-166,7
+166,7
@@
void output_html(void) {
}
/* Output our big pile of markup */
}
/* Output our big pile of markup */
- write(WC->http_sock, converted_msg, output_length);
+
http_
write(WC->http_sock, converted_msg, output_length);
/* A little trailing vertical whitespace... */
wprintf("<BR><BR>\n");
/* A little trailing vertical whitespace... */
wprintf("<BR><BR>\n");
diff --git
a/webcit/webcit.c
b/webcit/webcit.c
index 46623d1dafbd7630d76ee4b42e553011f4631808..d4d9cacc41f01bc46355aebc550ebc4298015749 100644
(file)
--- 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;
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);
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;
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);
print_standard_html_head = controlcode & 0x03;
refresh30 = ((controlcode & 0x04) >> 2);
@@
-304,12
+332,23
@@
void output_headers(int controlcode)
httpdate(httpnow, time(NULL));
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");
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);
}
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");
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"
wprintf("<HTML><HEAD><TITLE>");
escputs(serv_info.serv_humannode);
wprintf("</TITLE>\n"
@@
-452,7
+498,7
@@
void output_static(char *what)
bigbuffer = malloc(bytes);
fread(bigbuffer, bytes, 1, fp);
fclose(fp);
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")) {
free(bigbuffer);
}
if (!strcasecmp(bstr("force_close_session"), "yes")) {
@@
-497,7
+543,7
@@
void output_image()
else {
memset(xferbuf, 0, 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;
}
bytes = bytes - thisblock;
accomplished = accomplished + thisblock;
}
@@
-548,7
+594,7
@@
void output_mimepart()
else {
memset(xferbuf, 0, 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;
}
bytes = bytes - thisblock;
accomplished = accomplished + thisblock;
}
@@
-804,6
+850,13
@@
void session_loop(struct httprequest *req, int gzip)
WC->is_wap = 0;
WC->is_wap = 0;
+ if (gzip) {
+ WC->gzcompressed = 1;
+ }
+ else {
+ WC->gzcompressed = 0;
+ }
+
hptr = req;
if (hptr == NULL) return;
hptr = req;
if (hptr == NULL) return;
@@
-1183,4
+1236,12
@@
SKIP_ALL_THIS_CRAP:
free(WC->upload);
WC->upload_length = 0;
}
free(WC->upload);
WC->upload_length = 0;
}
+
+#ifdef WITH_ZLIB
+ if (WC->gzfd) {
+ gzclose(WC->gzfd);
+ WC->gzfd = NULL;
+ WC->gzcompressed = 0;
+ }
+#endif
}
}
diff --git
a/webcit/webcit.h
b/webcit/webcit.h
index a442b725e810e958937c5bf8cb595609f4382583..4aac82df13adc3984ea2b00c16c34bbf7ebd91f0 100644
(file)
--- a/
webcit/webcit.h
+++ b/
webcit/webcit.h
@@
-1,5
+1,9
@@
/* $Id$ */
/* $Id$ */
+#ifdef WITH_ZLIB
+#include <zlib.h>
+#endif
+
#define SIZ 4096 /* generic buffer size */
#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
#define SIZ 4096 /* generic buffer size */
#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
@@
-164,6
+168,10
@@
struct wcsession {
char this_page[SIZ]; /* address of current page */
char http_host[SIZ]; /* HTTP Host: header */
char *preferences;
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,'|')
};
#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|')
@@
-332,3
+340,4
@@
void rename_floor(void);
void do_listsub(void);
void toggle_self_service(void);
void summary(void);
void do_listsub(void);
void toggle_self_service(void);
void summary(void);
+ssize_t write(int fd, const void *buf, size_t count);