Created
May 16, 2011 16:42
-
-
Save bluescreen303/974811 to your computer and use it in GitHub Desktop.
node http proxy - fix for websockets?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -urN http-proxy/lib/node-http-proxy.js http-proxy-fixes/lib/node-http-proxy.js | |
--- http-proxy/lib/node-http-proxy.js 2011-05-16 18:23:58.746129001 +0200 | |
+++ http-proxy-fixes/lib/node-http-proxy.js 2011-05-16 18:37:53.876129001 +0200 | |
@@ -585,10 +585,6 @@ | |
var agent = _getAgent(options.host, options.port), | |
remoteHost = options.host + (options.port - 80 === 0 ? '' : ':' + options.port); | |
- // Change headers | |
- req.headers.host = remoteHost; | |
- req.headers.origin = 'http://' + options.host; | |
- | |
outgoing = { | |
host: options.host, | |
port: options.port, | |
@@ -614,30 +610,7 @@ | |
if (typeof request.socket !== 'undefined') { | |
request.socket.on('data', handshake = function(data) { | |
// Handshaking | |
- | |
- // Ok, kind of harmfull part of code | |
- // Socket.IO is sending hash at the end of handshake | |
- // If protocol = 76 | |
- // But we need to replace 'host' and 'origin' in response | |
- // So we split data to printable data and to non-printable | |
- // (Non-printable will come after double-CRLF) | |
- var sdata = data.toString(); | |
- | |
- // Get Printable | |
- sdata = sdata.substr(0, sdata.search(CRLF + CRLF)); | |
- | |
- // Get Non-Printable | |
- data = data.slice(Buffer.byteLength(sdata), data.length); | |
- | |
- // Replace host and origin | |
- sdata = sdata.replace(remoteHost, options.host) | |
- .replace(remoteHost, options.host); | |
- | |
try { | |
- // Write printable | |
- socket.write(sdata); | |
- | |
- // Write non-printable | |
socket.write(data); | |
} | |
catch (e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment