Roxen.git
/
server
/
plugins
/
protocols
/
http.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/plugins/protocols/http.pike:1:
// This is a roxen protocol module. // Modified by Francesco Chemolli to add throttling capabilities. // Copyright © 1996 - 2001, Roxen IS.
-
constant cvs_version = "$Id: http.pike,v 1.
375
2002/07/03
14
:
52
:
10
per
Exp $";
+
constant cvs_version = "$Id: http.pike,v 1.
376
2002/07/03
19
:
23
:
57
nilsson
Exp $";
// #define REQUEST_DEBUG #define MAGIC_ERROR
-
#ifdef MAGIC_ERROR
-
inherit "highlight_pike";
-
#endif
-
+
// HTTP protocol module. #include <config.h> #define TIMER_PREFIX "http:" #include <timers.h> inherit RequestID; #ifdef PROFILE #define HRTIME() gethrtime() #define HRSEC(X) ((int)((X)*1000000))
Roxen.git/server/plugins/protocols/http.pike:1052:
<td align='right'><font size='+1'>Internet Server " + Roxen.html_encode_string (roxen_version()) + #"</font></td> </tr></table> "; } string format_backtrace(int eid) { [string msg, array(string) rxml_bt, array(array) bt, string raw_bt_descr, string raw_url, string raw] =
-
roxen.query
_
var
("
errors
"
)[
eid
]
;
+
cache
_
lookup(
"
http_bt_error
"
, eid
);
string res = error_page_header ("Internal Server Error") + "<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>" + Roxen.html_encode_string (line) + "</li>\n"; res += "</ul>\n\n"; }
Roxen.git/server/plugins/protocols/http.pike:1116:
return "No backtrace"; if(sscanf(what, "%suthorization:%s\n%s", a, b, c)==3) return a+"uthorization: ################ (censored)\n"+c; return what; } int store_error(mixed _err) { mixed err = _err; _err = 0; // hide in backtrace, they are bad enough anyway...
-
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
;
+
int id
;
+
do {
+
id =
random(0xffffffff)
;
+
} while(!cache_lookup("http_bt_error", id));
string msg; array(string) rxml_bt; if (!err) msg = "Unknown error"; else { msg = describe_error (err); // Ugly, but it's hard to fix it better.. int i = search (msg, "\nRXML frame backtrace:\n"); if (i >= 0) {
Roxen.git/server/plugins/protocols/http.pike:1189:
descr = func + "()"; } else if (stringp (ent)) descr = ent; else if (catch (descr = sprintf ("%O", ent))) descr = "???"; bt += ({({file, line, func, descr})}); } } add_cvs_ids (err);
-
e[id]
=
({msg,rxml_bt,bt,describe_backtrace (err),raw_url,censor(raw)});
+
cache_set( "http_bt_error",
id
,
({msg,rxml_bt,bt,describe_backtrace (err),raw_url,censor(raw)})
)
;
return id; } array get_error(string eid) {
-
mapping
e = roxen.query
_
var
("
errors
"
);
-
if
(
e) return e[(
int)eid
];
-
return 0
;
+
return
cache
_
lookup
(
"
http_bt_error
"
,
(int)eid
)
;
} void internal_error(array _err) { misc->cacheable = 0; mixed err = _err; _err = 0; // hide in backtrace, they are bad enough anyway... array err2; if(port_obj && port_obj->query("show_internals"))
Roxen.git/server/plugins/protocols/http.pike:1326:
int off = 49; array (string) lines = data/"\n"; int start = (int)variables->line-50; if(start < 0) { off += start; start = 0; } int end = (int)variables->line+50;
-
// 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], Roxen.html_encode_string); if(sizeof(lines)>off) { sscanf (lines[off], "%[ \t]%s", string indent, string code); if (!sizeof (code)) code = " "; lines[off] = indent + "<font size='+1'><b>"+down+code+"</a></b></font></a>"; } lines[max(off-20,0)] = "<a name=here>"+lines[max(off-20,0)]+"</a>"; return error_page_header (variables->file) +