Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.oldstuff.proxyServer.daemon
on daemon (pta, httpRequest=nil) {
while system.temp.Frontier.startingUp { //6.0, wait here until Frontier has finished starting up
if (defined (user.webserver.prefs.flWaitDuringStartup)) and (not user.webserver.prefs.flWaitDuringStartup) { //PBS 3/19/99
break};
thread.sleepFor (1)};
if httpRequest != nil {
pta^.request = httpRequest}
else {
pta^.request = string (webserver.util.readUntil (pta^.stream, "\r\n\r\n", pta^.timeout))};
new (tableType, @pta^.requestHeaders);
pta^.firstLine = webserver.util.parseHeaders (pta^.request, @pta^.requestHeaders);
if defined (pta^.requestHeaders.Expect) {
return (webserver.util.buildResponse (417))}; // we can't live up to the client's expectations
bundle { //now that the headers are parsed, make sure we have the whole body
pta^.requestBody = "";
if defined (pta^.requestHeaders.["Content-Length"]) {
local (len = number (pta^.requestHeaders.["Content-Length"]));
local (ix = string.patternmatch ("\r\n\r\n", pta^.request));
pta^.requestBody = string.delete (pta^.request, 1, ix + 3);
if sizeOf (pta^.requestBody) < len {
local (bytesToRead = len - sizeOf (pta^.requestBody));
local (bytes = webserver.util.readBytes (pta^.stream, bytesToRead, pta^.timeout));
pta^.requestBody = pta^.requestBody + bytes};
if sizeOf (pta^.requestBody) < len {
<<we couldn't read the whole body for some reason
return (webserver.util.buildResponse (400, nil, webserver.util.buildErrorPage ("400 Bad Request", "The request body couldn't be read.")))};
if sizeOf (pta^.requestBody) > len { // strip off any traling junk
pta^.requestBody = string.delete (pta^.requestBody, len +1, infinity)}}};
<<scratchpad.params = pta^; edit (@scratchpad.params)
scratchpad.httpRequest = httpRequest;
return ("hello world")}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.