Branch: Tag:

2000-03-07

2000-03-07 17:52:16 by Martin Stjernholm <mast@lysator.liu.se>

Documented an API to tell internal and external requests apart. Added
cookie and user-agent headers to the file cache in try_get_file().

Rev: server/base_server/configuration.pike:1.270

3:   //   // German translation by Kai Voigt    - constant cvs_version = "$Id: configuration.pike,v 1.269 2000/03/06 18:57:11 nilsson Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.270 2000/03/07 17:52:16 mast Exp $";   constant is_configuration = 1;   #include <module.h>   #include <roxen.h>
1989:      // NOTE: A 'file' can be a cgi script, which will be executed, resulting in   // a horrible delay. + // + // Unless the not_internal flag is set, this tries to get an external + // or internal file. Here "internal" means a file that never should be + // sent directly as a request response. E.g. an internal redirect to a + // different file is still considered "external" since its contents is + // sent directly to the client. Internal requests are recognized by + // the id->misc->internal_get flag.   int|string try_get_file(string s, RequestID id, -  int|void status, int|void nocache) +  int|void status, int|void nocache, +  int|void not_internal)   { -  string res, q; +  string res, q, cache_key;    RequestID fake_id;    mapping m;   
2010:       fake_id->misc->common = id->misc->common;    -  if(!id->pragma["no-cache"] && !nocache && (!id->auth || !id->auth[0])) -  if(res = cache_lookup("file:"+id->conf->name, s)) +  if(!id->pragma["no-cache"] && !nocache && (!id->auth || !id->auth[0])) { +  cache_key = +  s + "\0" + +  id->request_headers->cookie + "\0" + +  id->request_headers["user-agent"]; +  if(res = cache_lookup("file:"+id->conf->name, cache_key))    return res; -  +  }       if(sscanf(s, "%s?%s", s, q))    {
2026:       fake_id->raw_url=s;    fake_id->not_query=s; +  if (!not_internal)    fake_id->misc->internal_get=1;       if(!(m = get_file(fake_id)))
2060:    if(!sscanf(res, "%*s\n\n%s", res))    sscanf(res, "%*s\n%s", res);    } -  if (!id->auth || !id->auth[0]) -  cache_set("file:"+id->conf->name, s, res); +  if (cache_key) +  cache_set("file:"+id->conf->name, cache_key, res);    return res;   }