Branch: Tag:

1999-02-15

1999-02-15 23:24:30 by Per Hedbor <ph@opera.com>

Now uses functions from configuration.pike instead

Rev: server/protocols/http.pike:1.125

6: Inside #if defined(MAGIC_ERROR)
  #ifdef MAGIC_ERROR   inherit "highlight_pike";   #endif - constant cvs_version = "$Id: http.pike,v 1.124 1999/01/14 02:49:37 neotron Exp $"; + constant cvs_version = "$Id: http.pike,v 1.125 1999/02/15 23:24:30 per Exp $";   // HTTP protocol module.   #include <config.h>   private inherit "roxenlib";
38:   #endif      constant decode = MIME.decode_base64; - constant find_supports = roxen->find_supports; - constant version = roxen->version; - constant handle = roxen->handle; - constant _query = roxen->query; - constant thepipe = roxen->pipe; + constant find_supports = roxen.find_supports; + constant version = roxen.version; + constant _query = roxen.query; + constant thepipe = roxen.pipe;   constant _time = predef::time;      private static array(string) cache;
233:    string a, b, linename, contents;    int config_in_url;    - // roxen->httpobjects[my_id] = "Parsed data..."; +     raw = s;       if (!line) {
358:       if(sizeof(s)) {   // sscanf(s, "%s\r\n\r\n%s", s, data); -  +    // s = replace(s, "\n\t", ", ") - "\r";   // Handle rfc822 continuation lines and strip \r -  +     foreach(s/"\r\n" - ({ "" }), line)    {    linename=contents=0;
750:    // second is the actual function,    // rest is backtrace.    -  string reason = roxen->diagnose_error( bt ); +  string reason = roxen.diagnose_error( bt );    if(sizeof(bt) == 1) // No backtrace?!    bt += ({ "Unknown error, no backtrace."});    string res = ("<title>Internal Server Error</title>"
802:   {    add_id(from);    return ("<pre>"+html_encode_string("Roxen version: "+version()+ -  (roxen->real_version != version()? -  " ("+roxen->real_version+")":"")+ +  (roxen.real_version != version()? +  " ("+roxen.real_version+")":"")+    "\nRequested URL: "+u+"\n"    "\nError: "+    describe_backtrace(from)-(getcwd()+"/")+
820:      int store_error(array err)   { -  mapping e = roxen->query_var("errors"); -  if(!e) roxen->set_var("errors", ([])); -  e = roxen->query_var("errors"); /* threads... */ +  mapping e = roxen.query_var("errors"); +  if(!e) roxen.set_var("errors", ([])); +  e = roxen.query_var("errors"); /* threads... */       int id = ++e[0];    if(id>1024) id = 1;
832:      array get_error(string eid)   { -  mapping e = roxen->query_var("errors"); +  mapping e = roxen.query_var("errors");    if(e) return e[(int)eid];    return 0;   }
997:    int tmp;    mapping heads;    string head_string; -  object thiso = this_object(); -  +     if (result) {    file = result;    }
1009:    file = http_low_answer(misc->error_code, errors[misc->error]);    else if(err = catch {    file=http_low_answer(404, -  replace(conf->parse_rxml(conf->query("ZNoSuchFile"), -  thiso), +  replace(parse_rxml(conf->query("ZNoSuchFile"), +  this_object()),    ({"$File", "$Me"}),    ({not_query,    conf->query("MyWorldLocation")})));
1161:   // Execute the request   void handle_request( )   { -  mixed *err; -  function funp; -  object thiso=this_object(); -  +    #ifdef MAGIC_ERROR    if(prestate->old_error)    {
1186: Inside #if defined(MAGIC_ERROR)
   else    {    array auth = (realauth+":")/":"; -  if((auth[0] != roxen->query("ConfigurationUser")) -  || !crypt(auth[1], roxen->query("ConfigurationPassword"))) +  if((auth[0] != roxen.query("ConfigurationUser")) +  || !crypt(auth[1], roxen.query("ConfigurationPassword")))    file = http_auth_required("admin");    else    file = ([
1202:    }   #endif /* MAGIC_ERROR */    -  +     remove_call_out(do_timeout);    MARK_FD("HTTP handling request"); -  if(!file && conf) +  +  array e; +  if(conf)    { - // perror("Handle request, got conf.\n"); -  object oc = conf; -  foreach(conf->first_modules(), funp) +  if(e= catch(file = conf->handle_request( this_object() ))) +  internal_error( e ); +  } +  else if(!file&&(e=catch(file=roxen.configuration_parse(this_object()))))    { -  if(file = funp( thiso)) break; -  if(conf != oc) { -  handle_request(); -  return; +  if(e==-1) return; +  internal_error(e);    } -  } -  if(!file) err=catch(file = conf->get_file(thiso)); -  -  if(err) internal_error(err); -  -  if(!mappingp(file)) { -  mixed ret; -  foreach(conf->last_modules(), funp) if(ret = funp(thiso)) break; -  if (ret == 1) { -  // Recurse. -  handle_request(); -  return; -  } -  file = ret; -  } -  } else if(!file && -  (err=catch(file = roxen->configuration_parse( thiso )))) { -  if(err==-1) return; -  internal_error(err); -  } -  +     send_result();   }   
1296:    my_fd->set_close_callback(0);    my_fd->set_read_callback(0);    processed=1; - #ifdef THREADS -  roxen->handle(this_object()->handle_request); - #else -  handle_request(); - #endif +  roxen.handle(this_object()->handle_request);   }      /* Get a somewhat identical copy of this object, used when doing