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.24 2009/11/14 12:26:04 mast Exp $ + // $Id: Session.pike,v 1.25 2010/03/07 21:48:27 srb 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:742:    if (!--connections_host_n[lookup])    m_delete(connections_host_n,lookup);    freed_connection(lookup);   }      // ================================================================      Request do_method_url(string method,    string url,    void|mapping query_variables, -  void|string data, +  void|string|mapping data,    void|mapping extra_headers)   { -  if (method=="POST") +  if (mappingp(data)) +  { +  data = http_encode_query(data);    extra_headers=    (["content-type":"application/x-www-form-urlencoded"])+    (extra_headers||([])); -  +  }       Request p=Request();    p->do_sync(p->prepare_method(method,url,query_variables,    extra_headers,data));    return p->ok() && p;   }      //! @decl Request get_url(URL url, @   //! void|mapping query_variables)   //! @decl Request post_url(URL url, @ - //! mapping query_variables) + //! mapping|string query_variables)   //! @decl Request put_url(URL url,string file, @   //! void|mapping query_variables)   //! @decl Request delete_url(URL url, @   //! void|mapping query_variables)   //! Sends a HTTP GET, POST, PUT or DELETE request to the server in the URL   //! and returns the created and initialized @[Request] object.   //! 0 is returned upon failure.   //!      Request get_url(URL url,
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:789:    return do_method_url("PUT", url, query_variables, file);   }      Request delete_url(URL url,    void|mapping query_variables)   {    return do_method_url("DELETE", url, query_variables);   }      Request post_url(URL url, -  mapping query_variables) +  mapping|string query_variables)   { -  return do_method_url("POST", url, 0, -  http_encode_query(query_variables)); +  return do_method_url("POST", url, 0, query_variables);   }         //! @decl array(string) get_url_nice(URL url, @   //! mapping query_variables)   //! @decl string get_url_data(URL url, @   //! mapping query_variables)   //! @decl array(string) post_url_nice(URL url, @ - //! mapping query_variables) + //! mapping|string query_variables)   //! @decl string post_url_data(URL url, @ - //! mapping query_variables) + //! mapping|string query_variables)   //! Returns an array of @expr{({content_type,data})@} and   //! just the data string respective,   //! after calling the requested server for the information.   //! @expr{0@} is returned upon failure.   //!   //! post* is similar to the @[get_url()] class of functions,   //! except that the query variables is sent as a POST request instead   //! of as a GET.   //!   
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:830:      string get_url_data(URL url,    void|mapping query_variables)   {    Request z = get_url(url, query_variables);    return z && z->data();   }         array(string) post_url_nice(URL url, -  mapping query_variables) +  mapping|string query_variables)   {    object c = post_url(url, query_variables);    return c && ({ c->headers["content-type"], c->data() });   }      string post_url_data(URL url, -  mapping query_variables) +  mapping|string query_variables)   {    Request z = post_url(url, query_variables);    return z && z->data();   }      // ================================================================   // async operation      Request async_do_method_url(string method,    URL url,    void|mapping query_variables, -  void|string data, +  void|string|mapping data,    void|mapping extra_headers,    function callback_headers_ok,    function callback_data_ok,    function callback_fail,    array callback_arguments)   {    if(stringp(url)) url=Standards.URI(url);       Request p=Request();       p->set_callbacks(callback_headers_ok,    callback_data_ok,    callback_fail,    p,@callback_arguments);    -  if (method=="POST") +  if (mappingp(data)) +  { +  data = http_encode_query(data);    extra_headers=    (["content-type":"application/x-www-form-urlencoded"])+    (extra_headers||([])); -  +  }       p->do_async(p->prepare_method(method,url,query_variables,    extra_headers,data));    return p;   }         //! @decl Request async_get_url(URL url,@   //! void|mapping query_variables,@   //! function callback_headers_ok,@
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:957:    function callback_data_ok,    function callback_fail,    mixed ...callback_arguments)   {    return async_do_method_url("DELETE", url, query_variables, 0,0,    callback_headers_ok,callback_data_ok,    callback_fail,callback_arguments);   }      Request async_post_url(URL url, -  mapping query_variables, +  mapping|string query_variables,    function callback_headers_ok,    function callback_data_ok,    function callback_fail,    mixed ...callback_arguments)   { -  return async_do_method_url("POST", url, 0, -  http_encode_query(query_variables),0, +  return async_do_method_url("POST", url, 0, query_variables, 0,    callback_headers_ok,callback_data_ok,    callback_fail,callback_arguments);   }      // ----------------------------------------------------------------   //      //! Class to store URL+referer   class SessionURL   {