f41b982009-05-07Martin Stjernholm // This is a roxen module. Copyright © 1996 - 2009, Roxen IS.
d1f9661997-04-09Per Hedbor  inherit "module";
0917d32013-03-04Anders Johansson constant cvs_version = "$Id$";
ddb7062000-02-10Martin Nilsson constant thread_safe = 1; constant module_type = MODULE_FIRST; constant module_name = "Automatic sending of compressed files";
664ecf2000-10-13Martin Nilsson constant module_doc = "This module implements a suggestion by Francesco Chemolli:<br />\n"
ddb7062000-02-10Martin Nilsson  "The modified filesystem should do\n"
664ecf2000-10-13Martin Nilsson  "about this:<br />\n" "<ul><li>check if the browser supports on-the-fly decompression</li>\n" "<li>check if a precompressed file already exists.</li>\n" "<li>if so, send a redirection to the precompressed file</li></ul>\n" "<p>So, no cost for compression, all URLs, content-types and such would "
ddb7062000-02-10Martin Nilsson  "remain vaild, no compression overhead and should be really simple " "to implement. Also, it would allow a site mantainer to "
664ecf2000-10-13Martin Nilsson  "choose WHAT to precompress and what not to." "This module acts as a filter, and it <i>will</i> use one extra stat " "per access from browsers that support automatic decompression.</p>"; mapping first_try(RequestID id) {
d1f9661997-04-09Per Hedbor  if(id->supports->autogunzip &&
664ecf2000-10-13Martin Nilsson  id->conf->real_file(id->not_query + ".gz", id) && id->conf->stat_file(id->not_query + ".gz", id))
d1f9661997-04-09Per Hedbor  { id->not_query += ".gz";
b796b51998-11-18Per Hedbor  return id->conf->get_file( id );
d1f9661997-04-09Per Hedbor  }
664ecf2000-10-13Martin Nilsson  return 0;
d1f9661997-04-09Per Hedbor }