Branch: Tag:

2002-10-07

2002-10-07 12:23:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Improved behaviour for the Expiry and Last-Modified headers.

Rev: server/protocols/http.pike:1.376

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2001, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.375 2002/09/20 16:03:07 jonasw Exp $"; + constant cvs_version = "$Id: http.pike,v 1.376 2002/10/07 12:23:52 grubba Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR   
1656:       if ( fstat[ST_MTIME] > misc->last_modified )    misc->last_modified = fstat[ST_MTIME]; +  }    -  if( misc->cacheable < INITIAL_CACHEABLE ) +  if( misc->cacheable < INITIAL_CACHEABLE ) {    heads["Expires"] = Roxen.http_date( predef::time(1)+misc->cacheable );    -  +  if (!misc->cacheable && !misc->last_modified) { +  // Data with immediate expiry is assumed to have been generated +  // at the same instant. +  misc->last_modified = predef::time(1); +  } +  } +  +  if (misc->last_modified)    heads["Last-Modified"] = Roxen.http_date(misc->last_modified);    -  + // werror("lm: %O\n" + // "cacheable: %O\n", + // misc->last_modified, + // misc->cacheable); +     if(since)    {    /* ({ time, len }) */    array(int) since_info = Roxen.parse_since( since ); - // werror("since: %{%O, %}\n" - // "lm: %O\n" - // "cacheable: %O\n", - // since_info, - // misc->last_modified, - // misc->cacheable); + // werror("since: %{%O, %}\n" + // "lm: %O\n" + // "cacheable: %O\n", + // since_info, + // misc->last_modified, + // misc->cacheable);    if ( ((since_info[0] >= misc->last_modified) &&    ((since_info[1] == -1) || (since_info[1] == file->len)))    // never say 'not modified' if not cacheable at all.    && (misc->cacheable != 0)    // actually ok, or... - // || ((misc->cacheable>0) - // && (since_info[0] + misc->cacheable<= predef::time(1)) - // // cacheable, and not enough time has passed. + // || ((misc->cacheable>0) + // && (since_info[0] + misc->cacheable<= predef::time(1)) + // // cacheable, and not enough time has passed.    )    {    file->error = 304;
1687:    file->data="";    }    } -  } +        if(prot != "HTTP/0.9")    {