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.13 2003/10/22 19:18:24 jhs Exp $ + // $Id: Session.pike,v 1.14 2004/01/11 00:49:02 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:42:   //! the request will perform another request if the   //! HTTP answer is a 3xx redirect.   //! Default from the parent @[Session.follow_redirects].   //!   //! A redirect automatically turns into a GET request,   //! and all header, query, post or put information is dropped.   //! @bugs   //! Loops will currently not be detected, only the limit   //! works to stop loops.    int follow_redirects= // from parent, will count down -  function_object(object_program(this_object()))->follow_redirects; +  function_object(this_program)->follow_redirects;      //! Cookie callback. When a request is performed,   //! the result is checked for cookie changes and   //! additions. If a cookie is encountered, this   //! function is called. Default is to call   //! @[set_http_cookie] in the @[Session] object.    function(string,Standards.URI:mixed) cookie_encountered=set_http_cookie;      // ----------------   
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:166:    Standards.URI(con->headers->location,url_requested);       if(loc->scheme=="http" || loc->scheme=="https")    {    destroy(); // clear    args=prepare_method("GET",loc);    follow_redirects--;    continue;    }    } -  return this_object(); +  return this;    }    return 0;    }    }      // ---------------- thread      //! Start a request in the background, using a thread.   //! Call @[wait] to wait for the thread to finish.   //! Get arguments from @[prepare_method].   //! @returns   //! The called object.   //! @seealso   //! @[prepare_method], @[do_sync], @[do_async], @[wait]   //! @note   //! @[do_thread] does not rerun redirections automatically    Request do_thread(array(string|int|mapping) args)    {    if(!con) con=give_me_connection(url_requested);    con->thread_request(@args); -  return this_object(); +  return this;    }      //! Wait for the request thread to finish.   //! @returns   //! 0 upon failure, or the called object upon success.   //! @seealso   //! @[do_thread]    Request wait()    {    if (con->`()())    {    check_for_cookies(); -  return this_object(); +  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;
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:250:    Request do_async(array(string|int|mapping) args)    {    if(!con)    {    if (connections_host_n[connection_lookup(url_requested)]>=    maximum_connections_per_server ||    (!connections_kept_n &&    connections_inuse_n>=maximum_total_connections))    {    wait_for_connection(do_async,args); -  return this_object(); +  return this;    }    con=give_me_connection(url_requested);    }    con->set_callbacks(async_ok,async_fail);    con->async_request(@args); -  return this_object(); +  return this;    }       static void async_ok(object q)    {    check_for_cookies();       if (con->status>=300 && con->status<400 &&    con->headers->location && follow_redirects)    {    Standards.URI loc=
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:461:    {    array v=array_sscanf(indata,"%O\t%O=%O\t%O\t%O");    if (sizeof(v)!=5) error("Cookie.decode: parse error\n");    [site,key,data,expires,path]=v;    if (!stringp(site) ||    !stringp(key) ||    !stringp(data) ||    !stringp(path) ||    !intp(expires))    error("Cookie.decode: parse error\n"); -  return this_object(); +  return this;    }   }         //! Parse and set a cookie received in the HTTP protocol.   //! The cookie will be checked against current security levels et al.   void set_http_cookie(string cookie,Standards.URI at)   {    object c=Cookie();    c->from_http(cookie,at);
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:610:    string lookup;    Query q;       void create(string _lookup,Query _q)    {    lookup=_lookup;    q=_q;       call_out(disconnect,time_to_keep_unused_connections);    connection_cache[lookup]= -  (connection_cache[lookup]||({}))+({this_object()}); +  (connection_cache[lookup]||({}))+({this});    connections_kept_n++;    }       void disconnect()    { -  connection_cache[lookup]-=({this_object()}); +  connection_cache[lookup]-=({this});    if (!sizeof(connection_cache[lookup]))    m_delete(connection_cache,lookup);    remove_call_out(disconnect); // if called externally       if (q->con) destruct(q->con);    connections_kept_n--;    if (!--connections_host_n[lookup])    m_delete(connections_host_n,lookup);    destruct(q); -  destruct(this_object()); +  destruct(this);    }       Query use()    { -  connection_cache[lookup]-=({this_object()}); +  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)