Changeset 2386


Ignore:
Timestamp:
2001-05-08T16:58:59+12:00 (23 years ago)
Author:
jrm21
Message:

Now prints out an HTTP Last-modified: header for any request with the c=...
arg. We base this on the last date that either collect.cfg or build.cfg was
modified.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/receptionist.cpp

    r2379 r2386  
    2525
    2626// following line required to get fstream.filedesc() on darwin (Mac OS X)
     27// gcc 2.91 automatically defines this in stream.h
    2728#define _STREAM_COMPAT  1
    2829
     
    3738#include <time.h>
    3839#include <stdio.h>
     40// following 2 are for printing Last-modified http header.
     41#include <sys/stat.h>
     42#include <time.h>
     43
    3944#if defined (GSDL_USE_IOS_H)
    4045#include <fstream.h>
     
    4348#endif
    4449
    45 #if defined (__WIN32_)
     50#if defined (__WIN32__)
    4651#include "wincgiutils.h"
    4752#endif
     
    752757  } else if (response == content) {
    753758    // content response
     759
     760    // use the later of build.cfg and collect.cfg modification times
     761    // as the Last-modified: header, for caching values
     762    struct stat file_info;
     763    time_t latest=0;
     764
     765    text_t collectname="";
     766    collectname=args["c"];
     767    if (collectname != "") {
     768      text_t collectdir=filename_cat("collect",collectname);
     769      text_t buildcfg=filename_cat(collectdir,"index");
     770      buildcfg=filename_cat(buildcfg,"build.cfg");
     771      char *buildcfg_ptr=buildcfg.getcstr();
     772      text_t collectcfg=filename_cat(collectdir,"etc");
     773      collectcfg=filename_cat(collectcfg,"collect.cfg");
     774      char *collectcfg_ptr=collectcfg.getcstr();
     775
     776      if (stat(buildcfg_ptr, &file_info)) {
     777    // we got an error. Currently don't handle error :(
     778    //  logout <<
     779      } else {
     780    latest=file_info.st_mtime;
     781      }
     782   
     783      if (stat(collectcfg_ptr, &file_info)) {
     784    // error - unhandled for now
     785      } else {
     786    if (latest<file_info.st_mtime) latest=file_info.st_mtime;
     787      }
     788      delete buildcfg_ptr;
     789      delete collectcfg_ptr;
     790
     791      if (latest>0) {
     792    // print out modified time, "DDD, dd MMM YYYY hh:mm:ss" format
     793    // c library takes care of mem for this string... (has \n at end!!!!)
     794    contentout << "Last-modified: " << ctime(&latest);
     795      }
     796    }
     797
    754798    contentout << text_t2ascii << "Content-type: " << response_data << "\n\n";
    755799  } else {
Note: See TracChangeset for help on using the changeset viewer.