Branch: Tag:

2000-05-08

2000-05-08 00:08:23 by Martin Nilsson <mani@lysator.liu.se>

Don't inherit roxenlib.

Rev: server/protocols/http.pike:1.231

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2000, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.230 2000/04/28 15:51:45 nilsson Exp $"; + constant cvs_version = "$Id: http.pike,v 1.231 2000/05/08 00:08:23 nilsson Exp $";      #define MAGIC_ERROR   
12:      // HTTP protocol module.   #include <config.h> - private inherit "roxenlib"; +       #ifdef PROFILE   #define HRTIME() gethrtime()
148:    case string_to_utf8:    return string_to_utf8;    default: -  return _charset_decoder( Locale.Charset.encoder( (string)what ) )->decode; +  return Roxen._charset_decoder( Locale.Charset.encoder( (string)what ) )->decode;    }   }   
225:   void decode_charset_encoding( string|function(string:string) decoder )   {    if(stringp(decoder)) -  decoder = _charset_decoder( Locale.Charset.decoder(decoder) )->decode; +  decoder = Roxen._charset_decoder( Locale.Charset.decoder(decoder) )->decode;       if( misc->request_charset_decoded )    return;
410:       my_fd->write(prot + " 302 Config in cookie!\r\n"    "Set-Cookie: " -  + http_roxen_config_cookie(indices(config) * ",") + "\r\n" +  + Roxen.http_roxen_config_cookie(indices(config) * ",") + "\r\n"    "Location: " + url + "\r\n"    "Content-Type: text/html\r\n"    "Content-Length: 0\r\n\r\n");
432:    url = "/" + url;    }    -  url = add_pre_state(url, prestate); +  url = Roxen.add_pre_state(url, prestate);       if (base[-1] == '/') {    url = base + url[1..];
686:       REQUEST_WERR(sprintf("After prestate scan:%O", f));    -  not_query = simplify_path(f); +  not_query = Roxen.simplify_path(f);       REQUEST_WERR(sprintf("After simplify_path == not_query:%O", not_query));   
755:    break;       case "multipart/form-data": -  // werror("Multipart/form-data post detected\n"); +     object messg = MIME.Message(data, misc);    foreach(messg->body_parts, object part) {    if(part->disp_params->filename) {
966:    if(!supports->cookies)    config = prestate;    else -  if(conf -  && port_obj->query("set_cookie") +  if(port_obj->query("set_cookie")    && !cookies->RoxenUserID && strlen(not_query)    && not_query[0]=='/' && method!="PUT")    {    if (!(port_obj->query("set_cookie_only_once") &&    cache_lookup("hosts_for_cookie",remoteaddr))) { -  misc->moreheads = ([ "Set-Cookie":http_roxen_id_cookie(), ]); +  misc->moreheads = ([ "Set-Cookie":Roxen.http_roxen_id_cookie(), ]);    }    if (port_obj->query("set_cookie_only_once"))    cache_set("hosts_for_cookie",remoteaddr,1);
1103:    if (!file || !line) return "<a>";    if(file[0]!='/') file = combine_path(getcwd(), file);    return ("<a href=\"/(old_error,find_file)/error/?"+ -  "file="+http_encode_string(file)+ -  (fun ? "&fun="+http_encode_string(fun) : "") + +  "file="+Roxen.http_encode_string(file)+ +  (fun ? "&fun="+Roxen.http_encode_string(fun) : "") +    "&off="+qq+    "&error="+eid+    (line ? "&line="+line+"#here" : "") +
1113:      static string error_page_header (string title)   { -  title = html_encode_string (title); +  title = Roxen.html_encode_string (title);    return #"<html><head><title>" + title + #"</title></head>   <body bgcolor='white' text='black' link='#ce5c00' vlink='#ce5c00'>   <table width='100%'><tr>   <td><a href='http://www.roxen.com/'><img border='0' src='/internal-roxen-roxen-small'></a></td>   <td><b><font size='+1'>" + title + #"</font></b></td> - <td align='right'><font size='+1'>Roxen WebServer " + html_encode_string (roxen_version()) + #"</font></td> + <td align='right'><font size='+1'>Roxen WebServer " + Roxen.html_encode_string (roxen_version()) + #"</font></td>   </tr></table>      ";
1132:    roxen.query_var ("errors")[eid];       string res = error_page_header ("Internal Server Error") + -  "<h1>" + replace (html_encode_string (msg), "\n", "<br />\n") + "</h1>\n"; +  "<h1>" + replace (Roxen.html_encode_string (msg), "\n", "<br />\n") + "</h1>\n";       if (rxml_bt && sizeof (rxml_bt)) {    res += "<h3>RXML frame backtrace</h3>\n<ul>\n";    foreach (rxml_bt, string line) -  res += "<li>" + html_encode_string (line) + "</li>\n"; +  res += "<li>" + Roxen.html_encode_string (line) + "</li>\n";    res += "</ul>\n\n";    }   
1147:    foreach(reverse (bt), [string file, int line, string func, string descr])    res += "<li value="+(q--)+">" +    link_to (file, line, func, eid, q) + -  (file ? html_encode_string (file) : "<i>Unknown program</i>") + +  (file ? Roxen.html_encode_string (file) : "<i>Unknown program</i>") +    (line ? ":" + line : "") + -  "</a>" + (file ? html_encode_string (get_id (file)) : "") + ":<br />\n" + -  replace (html_encode_string (descr), +  "</a>" + (file ? Roxen.html_encode_string (get_id (file)) : "") + ":<br />\n" + +  replace (Roxen.html_encode_string (descr),    ({"(", ")"}), ({"<b>(</b>", "<b>)</b>"})) +    "</li>\n";    res += "</ul>\n\n";
1267:    if(port_obj->query("show_internals"))    {    err2 = catch { -  file = http_low_answer(500, format_backtrace(store_error(err))); +  file = Roxen.http_low_answer(500, format_backtrace(store_error(err)));    };    if(err2) {    werror("Internal server error in internal_error():\n" +    describe_backtrace(err2)+"\n while processing \n"+    describe_backtrace(err)); -  file = http_low_answer(500, "<h1>Error: The server failed to " +  file = Roxen.http_low_answer(500, "<h1>Error: The server failed to "    "fulfill your query, due to an "    "internal error in the internal error routine.</h1>");    }    } else { -  file = http_low_answer(500, "<h1>Error: The server failed to " +  file = Roxen.http_low_answer(500, "<h1>Error: The server failed to "    "fulfill your query, due to an internal error.</h1>");    }    report_error("Internal server error: " +
1371:       // The highlighting doesn't work well enough on recent pike code.    //lines=highlight_pike("foo", ([ "nopre":1 ]), lines[start..end]*"\n")/"\n"; -  lines = map (lines[start..end], html_encode_string); +  lines = map (lines[start..end], Roxen.html_encode_string);       if(sizeof(lines)>off) {    sscanf (lines[off], "%[ \t]%s", string indent, string code);
1562:    if(!mappingp(file))    {    if(misc->error_code) -  file = http_low_answer(misc->error_code, errors[misc->error]); +  file = Roxen.http_low_answer(misc->error_code, errors[misc->error]);    else if(err = catch { -  file=http_low_answer(404, -  parse_rxml( +  file = Roxen.http_low_answer(404, +  Roxen.parse_rxml(   #ifdef OLD_RXML_COMPAT    replace(conf->query("ZNoSuchFile"),    ({"$File", "$Me"}),
1615:    }       if(prot != "HTTP/0.9") { -  heads["Last-Modified"] = http_date(misc->last_modified); +  heads["Last-Modified"] = Roxen.http_date(misc->last_modified);       if(since)    {
1661:   #else    "Connection" : "close",   #endif -  "Date" : http_date(time) +  "Date" : Roxen.http_date(time)    ]);      
1672:    file->error=200;       if(file->expires) -  heads->Expires = http_date(file->expires); +  heads->Expires = Roxen.http_date(file->expires);       if(mappingp(file->extra_heads))    heads |= file->extra_heads;
1825: Inside #if defined(MAGIC_ERROR)
   if(prestate->find_file)    {    if (!roxen.configuration_authenticate (this_object(), "View Settings")) -  file = http_auth_required("admin"); +  file = Roxen.http_auth_required("admin");    else    file = ([    "type":"text/html",
1906:       mixed q;    if( q = variables->magic_roxen_automatic_charset_variable ) -  decode_charset_encoding( get_client_charset_decoder( q,this_object() ) ); +  decode_charset_encoding( Roxen.get_client_charset_decoder( q,this_object() ) );    if( input_charset )    decode_charset_encoding( input_charset );