Re: advice on httpd sought

neuss@igd.fhg.de
Thu, 7 Oct 93 09:45:50 +0100


Dear fellow Webbers,

> I can't believe I'm alone in wanting to do this. Nor that no-one has
> thought of this way of doing it. Would someone therefore please very
> kindly tell me (and preferably offline if I am asking a really dim
> question) how to tell my httpd server that when it gets a request for a
> document with extension .blort it should pass said document through a
> filter FOO before serving it forth?

Hmpf.. no very obvious way to do so. I had to do a similar hacking, so
I can give some help here. I'll include a code fragment at the end of my

mail, if anyone out there needs further info, please feel free to send

me e-mail to neuss@igd.fhg.de. What I mainly did was modify send_file()
so that if the file name equals "gen.html", it would call up a special
conversion routine. Please note that I used the new HTTP 1.0 compliant

version of NCSA's httpd.

Peace, Chris

/*
* Christian Neuss % neuss@igd.fhg.de % ..in the humdrum
*/
==== snip ====
void send_file(char *file, FILE *fd, char *args) {
FILE *f;
if(!(f=fopen(file,"r"))) {
unmunge_name(file);
die(FORBIDDEN,file,fd); /* we've already established that it exists
*/
}
set_content_type(file);
#ifdef ICIB_HACK
{
char *base; int found=0;
for(base=file;*base;base++)if(*base=='/')found=1;
if(found){
for(;*base!='/';base--);
base++;
}else{
base=file;

}
if(strcmp(base,"gen.html")==0){
FILE *f2;
char *tmpfile;
tmpfile = tmpnam(NULL);
f2 = f;
f = fopen(tmpfile,"wb+");
if(f==NULL){
char err[MAX_STRING_LEN];
sprintf(err,"could not create temp file %s",tmpfile);
log_error(err);
}
ConvertTable(f2,f);
rewind(f);
send_fd(f,fd,args);
unlink(f);
return;
}
}
#endif /* ICIB_HACK */

send_fd(f,fd,args);
}