Branch: Tag:

2003-03-20

2003-03-20 20:05:54 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

some minor fixes + one major fix (copy_value of default headers is a good thing)

Rev: lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:1.9

1:   #pike __REAL_VERSION__    - // $Id: Session.pike,v 1.8 2003/03/13 22:47:02 nilsson Exp $ + // $Id: Session.pike,v 1.9 2003/03/20 20:05:54 mirar Exp $      import Protocols.HTTP;   
92:    "protocol than HTTP\n",    url->scheme);   #endif -  mapping request_headers = default_headers; +  mapping request_headers = copy_value(default_headers);    if (url->referer)    request_headers->referer=(string)url->referer;   
431:    switch (lower_case(what))    {    case "expires": -  werror("%O\n",value); +     expires=    (Calendar.ISO.parse("%e, %D %M %Y %h:%m:%s %z",value)||    Calendar.ISO.parse("%e, %D-%M-%y %h:%m:%s %z",value) )
494:    }    else    sc=cookie_lookup[cookie->site]=([]); +     sc[cookie->key]=cookie;    all_cookies[cookie]=1;   }
590:   //! Defaults to 50 connections.   int maximum_total_connections=50;    + //! Maximum times a connection is reused. + //! Defaults to 1000000. &lt;2 means no reuse at all. + int maximum_connection_reuse=1000000;    -  +    // internal (but readable for debug purposes)   mapping(string:array(KeptConnection)) connection_cache=([]);   int connections_kept_n=0;
660:    // clean up    q->buf="";    q->headerbuf=""; +  q->n_used++;    }    else    {
673:    one->disconnect(); // removes itself    }    -  q=Query(); +  q=SessionQuery();    q->hostname_cache=hostname_cache;    connections_host_n[connection_lookup(url)]++; // new    }
714:   {    connections_inuse_n--;    string lookup=connection_lookup(url); -  if (query->con) +  if (query->con && query->is_sessionquery)    {    if (query->headers->connection &&    lower_case(query->headers->connection)=="keep-alive" &&    connections_kept_n+connections_inuse_n    < maximum_total_connections && -  time_to_keep_unused_connections>0) +  time_to_keep_unused_connections>0 && +  query->n_used < maximum_connection_reuse)    {    // clean up    query->set_callbacks(0,0);
990:    referer=_referer;    }   } +  + class SessionQuery + { +  inherit Query; +  +  int n_used=1; +  constant is_sessionquery=1; + }