Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

Getting around modperl and mod_gzip quirks

Quote Reply
Getting around modperl and mod_gzip quirks
The typical modperl setup requires requests to be proxied to the modperl server (whether it be on its own server or combined with the httpd). The problem with proxies is that it buffers data before sending it. This however, becomes a problem with streaming content (such as the "Check Mail" popup). Here, I'll outline some things you can do to make such things work properly.

To get around the buffering, you will have to modify the templates to print out extra data to fill the buffer so it sends the data to the client. For Gossamer Mail, there is one template you need to modify:
pop_stream_hidden.htm
Code:
@@ -53,11 +53,13 @@
</head>
<body>
<%GMail::POP3::stream_info%>
+<%set flush = ' '%>
<%loop pop_list%>
<script type="text/javascript">
update_text("Checking Mail... <%pop_accounts_server%>", 1);
lock_text();
</script>
+ <%flush x 5120%>
<%GMail::POP3::stream_connect%>
<%if server_last%>
<%lastloop%>
@@ -78,6 +80,7 @@
update_bar();
<%endif%>
</script>
+ <%flush x 5120%>
<%if next_server%>
<%lastloop%>
<%endif%>

This change should ensure that the proxy's buffers are flushed when the POP3 dialog updates its status (note that depending on your setup, you may need to tweak the values).

However, most servers also use mod_gzip, which also will prevent streaming of data. One way to get around this is to make a copy of webmail.cgi (in this example, to webmails.cgi), and exclude this file from mod_gzip compressing the output. What's done below only needs to be done if you are using mod_gzip.

First copy or hard link the webmail.cgi binary (note that you will have to repeat this step after each upgrade):
Code:
cd /path/to/user
ln webmail.cgi webmails.cgi

Add the exclude to mod_gzip. admin.cgi and the installer also do some streaming, so we might as well exclude them.
Code:
mod_gzip_item_exclude file webmails\.cgi$
mod_gzip_item_exclude file admin\.cgi$
mod_gzip_item_exclude file install\.cgi$

Unfortunately, there's a bug in mod_gzip's exclude code and this also must be fixed. Here's a patch to fix this:
Code:
--- mod_gzip.c.old 2004-04-20 18:21:38.000000000 -0700
+++ mod_gzip.c 2004-04-20 18:23:45.000000000 -0700
@@ -386,7 +386,7 @@
checktarget = r__content_type;
}
else if ( ( this_type == MOD_GZIP_IMAP_ISFILE ) &&
- ( flen > 0 ) )
+ ( flen > 0 ) && strncmp(r__filename, "proxy:", 6) != 0 )
{
type_is_included = 1;
remove_vary = 1;
@@ -1509,7 +1509,7 @@
return DECLINED;
}

- if(r->filename) {
+ if(r->filename && strncmp(r->filename, "proxy:", 6) != 0) {
#ifdef MOD_GZIP_DEBUG1
mod_gzip_printf("%s: in r->filename, suffix is: %s, filename is: %s",cn,dconf->suffix,r->filename);
#endif
@@ -2317,7 +2317,7 @@
mod_gzip_printf("%s: i'm going to check r->filename",cn);
#endif

- if(r->filename) {
+ if(r->filename && strncmp(r->filename, "proxy:", 6) != 0) {
#ifdef MOD_GZIP_DEBUG1
mod_gzip_printf("%s: suffix is %s, filename is %s",cn,dconf->suffix,r->filename);
#endif

And lastly, change pop_stream.htm to use webmails.cgi:
Code:
@@ -5,8 +5,8 @@
<link href="login.cgi?t=<%t%>;page=style.css" rel="stylesheet" type="text/css" media="screen">
</head>
<frameset rows="100%,*">
- <frame name="status_bar" src="webmail.cgi?<%url_hidden%>;page=pop_stream_bar.htm;stream=1" scrolling="no" noresize frameborder="0" target="main">
- <frame name="stream_hidden" src="webmail.cgi?<%url_hidden%>;page=pop_stream_hidden.htm;stream=1" frameborder="0">
+ <frame name="status_bar" src="webmails.cgi?<%url_hidden%>;page=pop_stream_bar.htm;stream=1" scrolling="no" noresize frameborder="0" target="main">
+ <frame name="stream_hidden" src="webmails.cgi?<%url_hidden%>;page=pop_stream_hidden.htm;stream=1" frameborder="0">
<noframes>
<body>
<p>

Remember to restart your webserver for the mod_gzip changes to take effect.

Adrian

Last edited by:

Inertia: Oct 29, 2008, 5:07 PM
Subject Author Views Date
PostSticky: Getting around modperl and mod_gzip quirks brewt 7361 Sep 22, 2004, 12:45 PM