pike.git / lib / modules / Protocols.pmod / HTTP.pmod / Session.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:1:   #pike __REAL_VERSION__    - // $Id: Session.pike,v 1.21 2007/11/25 19:17:52 srb Exp $ + // $Id: Session.pike,v 1.22 2008/06/28 16:36:57 nilsson Exp $      import Protocols.HTTP;      typedef string|Standards.URI|SessionURL URL;      //! The number of redirects to follow, if any.   //! This is the default to the created Request objects.   //!   //! A redirect automatically turns into a GET request,   //! and all header, query, post or put information is dropped.
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:200:    if (con->`()())    {    check_for_cookies();    return this;    }    return 0;    }      // ---------------- async    -  static function(mixed...:mixed) headers_callback; -  static function(mixed...:mixed) data_callback; -  static function(mixed...:mixed) fail_callback; -  static array(mixed) extra_callback_arguments; +  protected function(mixed...:mixed) headers_callback; +  protected function(mixed...:mixed) data_callback; +  protected function(mixed...:mixed) fail_callback; +  protected array(mixed) extra_callback_arguments;      //! Setup callbacks for async mode,   //! @[headers] will be called when the request got connected,   //! and got data headers; @[data] will be called when the request   //! got the amount of data it's supposed to get and @[fail] is   //! called whenever the request failed.   //!   //! Note here that an error message from the server isn't   //! considered a failure, only a failed TCP connection.    void set_callbacks(function(mixed...:mixed) headers,
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:252:    wait_for_connection(do_async,args);    return this;    }    con=give_me_connection(url_requested);    }    con->set_callbacks(async_ok,async_fail);    con->async_request(@args);    return this;    }    -  static void async_ok(object q) +  protected void async_ok(object q)    {    check_for_cookies();       if (con->status>=300 && con->status<400 &&    con->headers->location && follow_redirects)    {    Standards.URI loc=    Standards.URI(con->headers->location,url_requested);       if(loc->scheme=="http" || loc->scheme=="https")
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:284:       // clear callbacks for possible garbation of this Request object    con->set_callbacks(0,0);       if (data_callback)    con->async_fetch(async_data); // start data downloading    else    extra_callback_arguments=0; // to allow garb    }    -  static void async_fail(object q) +  protected void async_fail(object q)    {    // clear callbacks for possible garbation of this Request object    con->set_callbacks(0,0);       array eca=extra_callback_arguments;    function fc=fail_callback;    set_callbacks(0,0,0); // drop all references       if (fc) fc(@eca); // note that we may be destructed here    }    -  static void async_data() +  protected void async_data()    {    // clear callbacks for possible garbation of this Request object    con->set_callbacks(0,0);       if (data_callback) data_callback(@extra_callback_arguments);    extra_callback_arguments=0; // clear references there too    }       void wait_for_connection(function callback,mixed ...args)    {
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:597:   //! Maximum times a connection is reused.   //! Defaults to 1000000. <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;   int connections_inuse_n=0;   mapping(string:int) connections_host_n=([]);    - static class KeptConnection + protected class KeptConnection   {    string lookup;    Query q;       void create(string _lookup,Query _q)    {    lookup=_lookup;    q=_q;       call_out(disconnect,time_to_keep_unused_connections);
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:640:    connection_cache[lookup]-=({this});    if (!sizeof(connection_cache[lookup]))    m_delete(connection_cache,lookup);    remove_call_out(disconnect);       connections_kept_n--;    return q; // subsequently, this object is removed (no refs)    }   }    - static inline string connection_lookup(Standards.URI url) + protected inline string connection_lookup(Standards.URI url)   {    return url->scheme+"://"+url->host+":"+url->port;   }      //! Request a @[Query] object suitable to use for the   //! given URL. This may be a reused object from a keep-alive   //! connection.   Query give_me_connection(Standards.URI url)   {    Query q;
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:688:    return q;   }      //   // called when there might be a free connection      // queue of what to call when we get new free connections   array(array) freed_connection_callbacks=({});    // ({lookup,callback,args})    - static inline void freed_connection(string lookup_freed) + protected inline void freed_connection(string lookup_freed)   {    if (connections_inuse_n>=maximum_total_connections)    return;       foreach (freed_connection_callbacks;;array v)    {    [string lookup, function callback, array args]=v;    if (lookup==lookup_freed ||    connections_host_n[lookup]<    maximum_connections_per_server)