httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Kallen <spida...@salon.com>
Subject testing modules, setting headers and PHP
Date Mon, 28 Jun 1999 18:37:51 GMT

Well, I've written to the Apache API via Perl plenty but I've taken a
stab at cachebusting via a regular old module <gulp., my first>.   I'm
curious if there's a standard set of abuse that I should subject a
server built with an experimental module to.  In my initial tests I
noticed that PHP seems to take over header setting (my module's Expires
and cache control headers seem to go away) but admittedly, I'm not
really conversant enough  with how the handling and tables do their
thing.

Any ideas on how to set these headers without PHP interfering and
general testbenching experimental modules welcome. My sorry ass code
follows,  thanks!

#include "httpd.h"
#include "http_config.h"

module cachekow_module;

static int mtime_header_fixup(request_rec *r)
{
   /* Don't add Expires headers to errors */
   if (ap_is_HTTP_ERROR(r->status))       
            return DECLINED;
   /* Say no to subrequests */
   if (r->main != NULL)        
            return DECLINED;
   /* Danger Will Robinson: no content type, no play */
   if (r->content_type == NULL)
            return DECLINED;
   /* We're sending HTML? */
   if (strcmp(r->content_type, "text/html") == 0) {   
      /* Send proxy cache control directives appropriate to the client
*/
      if (r->proto_num == HTTP_VERSION(1,0)) {
         ap_table_setn(r->headers_out, "Pragma","no-cache");
      }
      if (r->proto_num == HTTP_VERSION(1,1)) {
         ap_table_setn(r->headers_out, "Cache-Control","no-cache,
must-revalidate");
      }
      /* Send an Expires header */
      ap_table_setn(r->headers_out, "Expires",
ap_gm_timestr_822(r->pool, r->request_time));
      /* Put a bogus last modified value in the table */
      ap_update_mtime(r, r->request_time);
      ap_set_last_modified(r);
   }
   return DECLINED;
}

module MODULE_VAR_EXPORT cachekow_module =
{
    STANDARD_MODULE_STUFF,
    NULL,                       /* initializer */
    NULL,                       /* dir config creater */
    NULL,                       /* dir merger --- default is to override
*/
    NULL,                       /* server config */
    NULL,                       /* merge server configs */
    NULL,                       /* command table */
    NULL,                       /* handlers */
    NULL,                       /* filename translation */
    NULL,                       /* check_user_id */
    NULL,                       /* check auth */
    NULL,                       /* check access */
    NULL,                       /* type_checker */
    mtime_header_fixup,         /* fixups */
    NULL,                       /* logger */
    NULL,                       /* header parser */
    NULL,                       /* child_init */
    NULL,                       /* child_exit */
    NULL                        /* post read-request */
};







--
Salon Internet 				http://www.salon.com/
  HTTP mechanic, Perl diver, Mebwaster, Some of the above
	    Ian Kallen <idk@salon.com>

Mime
View raw message