public void ProcessRequest(int reqId, long localEPAddr, int localEPPort, long remoteEPAdds, int remoteEPPort, string verb, string path, string queryString, string protocol, byte [] inputBuffer, string redirect) { XSPRequestBroker broker = (XSPRequestBroker)RequestBroker; IPEndPoint localEP = new IPEndPoint(localEPAddr, localEPPort); IPEndPoint remoteEP = new IPEndPoint(remoteEPAdds, remoteEPPort); XSPWorkerRequest mwr = new XSPWorkerRequest(reqId, broker, this, localEP, remoteEP, verb, path, queryString, protocol, inputBuffer); string translated = mwr.GetFilePathTranslated(); if (path [path.Length - 1] != '/' && Directory.Exists(translated)) { redirect = path + '/'; } if (redirect != null) { Redirect(mwr, redirect); broker.UnregisterRequest(reqId); return; } ProcessRequest(mwr); }
static void Redirect(XSPWorkerRequest wr, string location) { string host = wr.GetKnownRequestHeader(HttpWorkerRequest.HeaderHost); wr.SendStatus(301, "Moved Permanently"); wr.SendUnknownResponseHeader("Connection", "close"); wr.SendUnknownResponseHeader("Date", DateTime.Now.ToUniversalTime().ToString("r")); wr.SendUnknownResponseHeader("Location", String.Format("http://{0}{1}", host, location)); Encoding enc = Encoding.ASCII; wr.SendUnknownResponseHeader("Content-Type", "text/html; charset=" + enc.WebName); string content = String.Format(content301, host, location); byte [] contentBytes = enc.GetBytes(content); wr.SendUnknownResponseHeader("Content-Length", contentBytes.Length.ToString()); wr.SendResponseFromMemory(contentBytes, contentBytes.Length); wr.FlushResponse(true); wr.CloseConnection(); }
public void Run (object state) { XSPWorkerRequest mwr = new XSPWorkerRequest (client, host); mwr.ProcessRequest (); }
static void Redirect (XSPWorkerRequest wr, string location) { string host = wr.GetKnownRequestHeader (HttpWorkerRequest.HeaderHost); wr.SendStatus (301, "Moved Permanently"); wr.SendUnknownResponseHeader ("Connection", "close"); wr.SendUnknownResponseHeader ("Date", DateTime.Now.ToUniversalTime ().ToString ("r")); wr.SendUnknownResponseHeader ("Location", String.Format ("http://{0}{1}", host, location)); Encoding enc = Encoding.ASCII; wr.SendUnknownResponseHeader ("Content-Type", "text/html; charset=" + enc.WebName); string content = String.Format (content301, host, location); byte [] contentBytes = enc.GetBytes (content); wr.SendUnknownResponseHeader ("Content-Length", contentBytes.Length.ToString ()); wr.SendResponseFromMemory (contentBytes, contentBytes.Length); wr.FlushResponse (true); wr.CloseConnection (); }
public void ProcessRequest (int reqId, long localEPAddr, int localEPPort, long remoteEPAdds, int remoteEPPort, string verb, string path, string queryString, string protocol, byte [] inputBuffer, string redirect) { XSPRequestBroker broker = (XSPRequestBroker) RequestBroker; IPEndPoint localEP = new IPEndPoint (localEPAddr, localEPPort); IPEndPoint remoteEP = new IPEndPoint (remoteEPAdds, remoteEPPort); XSPWorkerRequest mwr = new XSPWorkerRequest (reqId, broker, this, localEP, remoteEP, verb, path, queryString, protocol, inputBuffer); string translated = mwr.GetFilePathTranslated (); if (path [path.Length - 1] != '/' && Directory.Exists (translated)) redirect = path + '/'; if (redirect != null) { Redirect (mwr, redirect); broker.UnregisterRequest (reqId); return; } ProcessRequest (mwr); }
public void Run(object state) { XSPWorkerRequest mwr = new XSPWorkerRequest(client, host); mwr.ProcessRequest(); }