Roxen.git / server / plugins / protocols / http.pike

version» Context lines:

Roxen.git/server/plugins/protocols/http.pike:1:   // This is a ChiliMoon protocol module.   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2001, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.390 2002/11/02 03:25:24 mani Exp $"; + constant cvs_version = "$Id: http.pike,v 1.391 2002/11/14 23:31:48 mani Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR      // HTTP protocol module.   #include <config.h>   #define TIMER_PREFIX "http:"   #include <timers.h>      inherit RequestID;   
Roxen.git/server/plugins/protocols/http.pike:1436:    if(!(p=conf->profile_map[nid]))    p = conf->profile_map[nid] = ({0,0.0,0.0});    p[0]++;    p[1] += elapsed;    if(elapsed > p[2]) p[2]=elapsed;   #endif       REQUEST_WERR(sprintf("HTTP: response: prot %O, method %O, file %O",    prot, method, file));    -  if( prot == "HTTP/0.9" ) misc->cacheable = 0; -  +     if(!leftovers)    leftovers = data||"";       if(!mappingp(file))    {    misc->cacheable = 0;    if(misc->error_code)    file = Roxen.http_low_answer(misc->error_code, errors[misc->error]);    else if(err = catch {    file = conf->error_file( this_object() );
Roxen.git/server/plugins/protocols/http.pike:1491:    if( Stat fstat = file->stat )    {    if( !file->len )    file->len = fstat[1];       if ( fstat[ST_MTIME] > misc->last_modified )    misc->last_modified = fstat[ST_MTIME];    }       if( misc->cacheable < INITIAL_CACHEABLE ) { -  if (misc->cacheable == 0) +  if (misc->cacheable == 0) {    heads["Expires"] = Roxen.http_date( 0 ); -  else -  heads["Expires"] = Roxen.http_date( predef::time(1)+misc->cacheable ); +     -  if (!misc->cacheable && !misc->last_modified) { +  if (!misc->last_modified) {    // Data with immediate expiry is assumed to have been generated    // at the same instant.    misc->last_modified = predef::time(1);    }    } -  +  else +  heads["Expires"] = Roxen.http_date( predef::time(1)+misc->cacheable ); +  }       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 && (!file->error || file->error == 200) && misc->last_modified)    { -  /* ({ time, len }) */ +  // ({ 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); -  if ( ((since_info[0] >= misc->last_modified) && -  ((since_info[1] == -1) || (since_info[1] == file->len))) +  +  if ( (since_info[0] >= misc->last_modified) && +  ((since_info[1] == -1) || (since_info[1] == file->len))    // never say 'not modified' if cacheable has been lowered. -  && (misc->cacheable >= INITIAL_CACHEABLE) -  // actually ok, or... - // || ((misc->cacheable>0) - // && (since_info[0] + misc->cacheable<= predef::time(1)) - // // cacheable, and not enough time has passed. -  ) +  && (misc->cacheable >= INITIAL_CACHEABLE) )    {    file->error = 304;    file->file = 0;    file->data="";    }    }       if(prot != "HTTP/0.9")    {    string h, charset="";
Roxen.git/server/plugins/protocols/http.pike:1670: Inside #if defined(RAM_CACHE)
   {    if( file->len>0 && // known length.    ((file->len + strlen( head_string )) <    conf->datacache->max_file_size)    && misc->cachekey )    {    string data = "";    if( file->file ) data += file->file->read();    if( file->data ) data += file->data;    MY_TRACE_ENTER (sprintf ("Storing in ram cache, entry: %O", raw_url), 0); -  MY_TRACE_LEAVE (""); +     conf->datacache->set( raw_url, data,    ([    // We have to handle the date header.    "hs":head_string,    "key":misc->cachekey,    "callbacks":misc->_cachecallbacks,    "len":file->len,    // fix non-keep-alive when sending from cache    "raw":file->raw,    "error":file->error,    "mtime":(file->stat && file->stat[ST_MTIME]),    "rf":realfile,    ]),    misc->cacheable );    file = ([ "data":data, "raw":file->raw, "len":strlen(data) ]); -  +  MY_TRACE_LEAVE ("");    }    }   #endif    if(strlen(head_string))    send(head_string);    if(file->data && strlen(file->data))    send(file->data, file->len, file->start);    if(file->file)    send(file->file, file->len, file->start);    }