From 4b612baf4f29178214edec130856d83a40bf473d Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Sun, 4 Sep 2011 22:53:16 +0200 Subject: Total restructuring of files and deletion of old files --- chrome/code/proxyserver.js | 58 ---------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 chrome/code/proxyserver.js (limited to 'chrome/code/proxyserver.js') diff --git a/chrome/code/proxyserver.js b/chrome/code/proxyserver.js deleted file mode 100644 index 5d4f1d6..0000000 --- a/chrome/code/proxyserver.js +++ /dev/null @@ -1,58 +0,0 @@ -Components.utils.import("chrome://redirector/content/code/xpcom.js"); - -var EXPORTED_SYMBOLS = ['RedirectorProxy']; - -var RedirectorProxy = { - - start : function(port, getUrl) { - dump('Opening Proxy Server Socket on port ' + port); - this.getUrl = getUrl; - this.serverSocket = new ServerSocket(port, true, -1); - this.serverSocket.asyncListen(this); - }, - - onSocketAccepted: function(serverSocket, clientSocket) { - dump("Accepted connection on "+clientSocket.host+":"+clientSocket.port); - var requestStream = clientSocket.openInputStream(0, 0, 0).QueryInterface(Ci.nsIAsyncInputStream); - var responseStream = clientSocket.openOutputStream(Ci.nsITransport.OPEN_BLOCKING, 0, 0); - var tm = Cc["@mozilla.org/thread-manager;1"].getService(); - requestStream.asyncWait({ - onInputStreamReady : function(inputStream) { - RedirectorProxy.processRequest(clientSocket, inputStream, responseStream); - } - },0,0,tm.mainThread); - }, - - processRequest : function(clientSocket, inputStream, responseStream) { - var requestStream = new ScriptableInputStream(inputStream); - requestStream.available(); - var request = ''; - while (requestStream.available()) { - request = request + requestStream.read(2048); - } - var parts = request.split(' '); - dump('\n\n\n' + request + '\n\n\n'); - dump("\n" + parts[0] + " request for " + parts[1]); - var redirectUrl = 'http://einaregilsson.com';//Redirector.getRedirectUrl(parts[1]); - var outp = 'HTTP/1.1 302 Moved Temporarily'; - outp += '\r\nContent-Length: '; - outp += '\r\nLocation: ' + redirectUrl; - outp += '\r\nX-Redirected-By: Redirector Firefox Extension' - outp += '\r\n\r\n'; - var cl = outp.length -4; - if (cl < 100) { - cl+=2; - } else if (cl < 1000) { - cl += 3; - } else if (cl < 10000) { - cl += 4; - } else if (cl < 100000) { - cl += 5; - } - outp = outp.replace('', cl); - dump(outp); - responseStream.write(outp, outp.length); - responseStream.close(); - inputStream.close(); - } -} \ No newline at end of file -- cgit v1.2.3-70-g09d2