Roxen.git / server / plugins / protocols / http.pike

version» Context lines:

Roxen.git/server/plugins/protocols/http.pike:1:   // This is a ChiliMoon protocol module.   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2001, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.392 2003/01/14 22:53:37 zino Exp $"; + constant cvs_version = "$Id: http.pike,v 1.393 2003/01/23 16:21:02 mani Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR      // HTTP protocol module.   #include <config.h>   #define TIMER_PREFIX "http:"   #include <timers.h>      inherit RequestID;   
Roxen.git/server/plugins/protocols/http.pike:42:   #endif      #ifdef THROTTLING_DEBUG   #undef THROTTLING_DEBUG   #define THROTTLING_DEBUG(X) werror("Throttling: "+X+"\n")   #else   #define THROTTLING_DEBUG(X)   #endif      constant decode = MIME.decode_base64; - constant find_supports_and_vars = roxen.find_supports_and_vars; - constant version = roxen.version; - constant _query = roxen.query; + constant find_supports_and_vars = core.find_supports_and_vars; + constant version = core.version; + constant _query = core.query;      private static array(string) cache;   private static int wanted_data, have_data;      #include <roxen.h>   #include <module.h>   #include <variables.h>   #include <request_trace.h>      #define MY_TRACE_ENTER(A, B) \
Roxen.git/server/plugins/protocols/http.pike:116:    if( u = conf->authenticate( this_object() ) )    return 0;    if( realauth )    return ((realauth/":")[1..])*":";    }    }    int `!( )    {    return !realauth;    } -  string _sprintf() { return "AuthEmulator"; } +    }      AuthEmulator auth;      string charset_name( function|string what )   {    switch( f )    {    case string_to_unicode: return "ISO10646-1";    case string_to_utf8: return "UTF-8";
Roxen.git/server/plugins/protocols/http.pike:301:   Shuffler.Shuffle pipe;   object throttler; // The inter-request throttling object.      private void setup_pipe()   {    if(!my_fd)    {    end();    return;    } -  pipe = roxen.get_shuffler( my_fd ); +  pipe = core.get_shuffler( my_fd );    if( conf )    conf->connection_add( this_object(), pipe );   }         void send(string|object what, int|void len, int|void start)   {    if(!what) return;    if(!pipe) setup_pipe();    if( len>0 && port_obj && port_obj->minimum_byterate )
Roxen.git/server/plugins/protocols/http.pike:379: Inside #if defined(OLD_RXML_CONFIG)
   if(m[0]=='-')    config[m[1..]]=0;    else    config[m]=1;    return config;    };       void do_send_reply( string what, string url ) {    url = url_base() + url[1..];    my_fd->set_blocking(); -  my_fd->write( prot + " 302 Roxen config coming up\r\n"+ +  my_fd->write( prot + " 302 ChiliMoon config coming up\r\n"+    (what?what+"\r\n":"")+"Location: "+url+"\r\n"    "Connection: close\r\nDate: "+    Roxen.http_date(predef::time(1))+    "\r\nContent-Type: text/html\r\n"    "Content-Length: 1\r\n\r\nx" );    my_fd->close();    my_fd = 0;    end();    };   
Roxen.git/server/plugins/protocols/http.pike:412:   }   #endif      private static mixed f, line;   private static int hstart;      class CacheKey {   #if ID_CACHEKEY_DEBUG    constant __num = ({ 0 });    int _num; -  string _sprintf() { return "CacheKey(#" + _num + ")"; } +  string _sprintf(int t) { +  return t=='O' && sprintf("%O(#%d)", this_program, _num); +  }    void create() { _num = ++__num[0]; }    void destroy() { werror("CacheKey(#" + _num + "): --DESTROY--\n"    "%s\n\n", "" || describe_backtrace(backtrace())); }   #endif   }      //! Parse a cookie string.   //!   //! @param contents   //! HTTP transport-encoded cookie header value.   //!   //! @returns   //! Returns the resulting current cookie mapping.   mapping(string:string) parse_cookies( string contents )   {    if(!contents)    return cookies;    - // misc->cookies += ({contents}); +     foreach(((contents/";") - ({""})), string c)    {    string name, value;    while(sizeof(c) && c[0]==' ') c=c[1..];    if(sscanf(c, "%s=%s", name, value) == 2)    {    value=http_decode_string(value);    name=http_decode_string(name);    cookies[ name ]=value;   #ifdef OLD_RXML_CONFIG
Roxen.git/server/plugins/protocols/http.pike:997:       res += ("<p><b><a href=\"/(old_error,plain)/error/?error="+eid+"\">"    "Generate text only version of this error message, for bug reports"+    "</a></b></p>\n\n");    return res+"</body></html>";   }      string generate_bugreport(string msg, array(string) rxml_bt, array(string) bt,    string raw_bt_descr, string raw_url, string raw)   { -  return ("Roxen version: "+version()+ -  (roxen.real_version != version()? -  " ("+roxen.real_version+")":"")+ +  return ("ChiliMoon version: "+version()+ +  (core.real_version != version()? +  " ("+core.real_version+")":"")+    "\nPike version: " + predef::version() +    "\nRequested URL: "+raw_url+"\n"    "\nError: " + raw_bt_descr +    "\nRequest data:\n"+raw);   }      string censor(string what)   {    string a, b, c;    if(!what)
Roxen.git/server/plugins/protocols/http.pike:1350:    case "set_nonblocking":    return 0;       case "query_fd":    return lambda() { return -1; };       default:    return file[what];    }    } -  -  string _sprintf() { return "MultiRangeWrapper"; } +    }         // Parse the range header into multiple ranges.   array parse_range_header(int len)   {    array ranges = ({});    foreach(misc->range / ",", string range)    {    int r1, r2;
Roxen.git/server/plugins/protocols/http.pike:1713: Inside #if defined(MAGIC_ERROR)
   file = ([    "type":"text/plain",    "data":generate_bugreport( @err ),    ]);    TIMER_END(handle_request);    send_result();    return;    } else {    if(prestate->find_file)    { -  if (!roxen.configuration_authenticate (this_object(), "View Settings")) +  if (!core.configuration_authenticate(this_object(), "View Settings"))    file = Roxen.http_auth_required("admin");    else    file = ([    "type":"text/html",    "data":handle_error_file_request( @err ),    ]);    TIMER_END(handle_request);    send_result();    return;    }
Roxen.git/server/plugins/protocols/http.pike:1741:    array e;    if(e= catch(file = conf->handle_request( this_object() )))    INTERNAL_ERROR( e );       if( file )    if( file->try_again_later )    {    if( objectp( file->try_again_later ) )    ;    else -  call_out( roxen.handle, file->try_again_later, handle_request ); +  call_out( core.handle, file->try_again_later, handle_request );    return;    }    else if( file->pipe )    return;    TIMER_END(handle_request);    send_result();   }      string url_base()   // See the RequestID class for doc.
Roxen.git/server/plugins/protocols/http.pike:2042: Inside #if defined(RAM_CACHE)
   }    }    TIMER_END(cache_lookup);   #endif // RAM_CACHE    TIMER_START(parse_request);    if( things_to_do_when_not_sending_from_cache( ) )    return;    TIMER_END(parse_request);      #ifdef THREADS -  REQUEST_WERR("HTTP: Calling roxen.handle()."); -  roxen.handle(handle_request); +  REQUEST_WERR("HTTP: Calling core.handle()."); +  core.handle(handle_request);   #else    handle_request();   #endif    })    {    report_error("Internal server error: " + describe_backtrace(err));    my_fd->set_blocking();    my_fd->close();    disconnect();    }
Roxen.git/server/plugins/protocols/http.pike:2176:    if(do_not_disconnect == -1)    do_not_disconnect = 0;    if(!processed)    {    my_fd->set_read_callback(got_data);    my_fd->set_close_callback(end);    }    }   }    - string _sprintf( ) + string _sprintf(int t)   { -  +  if(t!='O') return 0;    return "RequestID(" + (raw_url||"") + ")"   #ifdef ID_OBJ_DEBUG    + (__marker ? "[" + __marker->count + "]" : "")   #endif    ;   }      Stdio.File connection( )   {    return my_fd;   }      Configuration configuration()   {    return conf;   }