Branch: Tag:

2006-04-20

2006-04-20 11:03:57 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Now uses the NO_PROTO_CACHE() macro to disable the protocol cache.
Added support for fetching from the protocol cache also for HTTP/0.9 requests.

Rev: server/protocols/http.pike:1.496

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2004, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.495 2006/03/21 16:18:53 grubba Exp $"; + constant cvs_version = "$Id: http.pike,v 1.496 2006/04/20 11:03:57 grubba Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR    -  + #define REQUESTID this +    #ifdef MAGIC_ERROR   inherit "highlight_pike";   #endif
578: Inside #if undefined(DISABLE_SUPPORTS)
   }    if ( client_var->charset && client_var->charset != "iso-8859-1" )    { -  misc->no_proto_cache = 1; // FIXME: Why? +  // FIXME: This code is suspect, and probably ought to be removed. +  NO_PROTO_CACHE(); // FIXME: Why?       set_output_charset( client_var->charset );    input_charset = client_var->charset;
713:    }    s = data = ""; // no headers or extra data...    sscanf( f, "%s%*[\r\n]", f ); -  misc->no_proto_cache = 1; +  if (sizeof(s1) == 1) +  NO_PROTO_CACHE();    break;       case 0:
1338:      void internal_error(array _err)   { -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    mixed err = _err;    _err = 0; // hide in backtrace, they are bad enough anyway...    array err2;
1670:    array ranges = parse_range_header(file->len);    if(ranges) // No incorrect syntax...    { -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    if(sizeof(ranges)) // And we have valid ranges as well.    {    m_delete(variant_heads, "Content-Length");
1846:    misc->no_proto_cache ? "disabled" : "enabled");   #endif    -  if( prot == "HTTP/0.9" ) misc->no_proto_cache = 1; +  if( prot == "HTTP/0.9" ) NO_PROTO_CACHE();       if(!leftovers)    leftovers = data||"";       if(!mappingp(file))    { -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    if(misc->error_code)    file = Roxen.http_status(misc->error_code, errors[misc->error_code]);    else if(err = catch {
1994:    // All conditionals apply.    file->error = conditional;    file->file = file->data = file->len = 0; -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    }    }   
2076:    head_string += "\r\n";    }    +  if (objectp(cookies)) { +  // Disconnect the cookie jar. +  cookies = ~cookies; +  } +     int varies = misc->vary && (sizeof(misc->vary) - misc->vary["Host"]);    if( (method == "HEAD") || (file->error == 204) || (file->error == 304) ||    (file->error < 200))
2452:    if (rawauth)    {    /* Need to authenticate with the configuration */ -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    array(string) y = rawauth / " ";    realauth = 0;    auth = 0;
2467:    if( misc->proxyauth )    {    /* Need to authenticate with the configuration */ -  misc->no_proto_cache = 1; +  NO_PROTO_CACHE();    if (sizeof(misc->proxyauth) >= 2)    {    // misc->proxyauth[1] = MIME.decode_base64(misc->proxyauth[1]);
2489: Inside #if defined(RAM_CACHE)
  #ifdef RAM_CACHE    TIMER_START(cache_lookup);    array cv; -  if( prot != "HTTP/0.9" && -  misc->cacheable && -  !misc->no_proto_cache && +  if(misc->cacheable && !misc->no_proto_cache &&    (cv = conf->datacache->get(raw_url, this_object())) )    {    MY_TRACE_ENTER(sprintf("Found %O in ram cache - checking entry",
2619: Inside #if defined(RAM_CACHE)
   code = file->error;    }    } -  string full_headers = prot + " " + code + file->hs + +  string full_headers = ""; +  if (prot != "HTTP/0.9") { +  full_headers = prot + " " + code + file->hs +    Roxen.make_http_headers(variant_heads); -  +  }       MY_TRACE_LEAVE ("Using entry from ram cache");    cache_status["protcache"] = 1;
2635: Inside #if defined(RAM_CACHE) and #if undefined(RAM_CACHE_ASUME_STATIC_CONTENT)
   sprintf ("Entry out of date (disk: %s, cache: mtime %d)",    st ? "mtime " + st->mtime : "gone", file->mtime));   #endif -  } else -  misc->no_proto_cache = 1; // Never cache in this case. +  }    file = 0;    }    }