-
-
Save dominictarr/1113432 to your computer and use it in GitHub Desktop.
node-http-proxy bug #70
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
var http = require('http') | |
function log (str) { | |
console.log('' + str) | |
} | |
http.get({host: 'localhost', port:6666, path: '/xhr'}, function (res) { | |
res.on('data', log) | |
res.on('end', log) | |
console.log('response', res) | |
}) |
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
<html> | |
<body> | |
JUHU | |
<script> | |
var req = new XMLHttpRequest(); | |
req.multipart = true; | |
req.open("GET", "/xhr"); | |
req.onload = function(){ | |
if (req.readyState == 4) | |
console.log("load:" + req.responseText); | |
}; | |
req.send(); | |
</script> | |
</body> | |
</html> |
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
var index = require("fs").readFileSync(__dirname + "/index.html"); | |
require("http").createServer(function(req, res) { | |
if (req.url == "/xhr") { | |
console.log("xhr") | |
var headers = {}; | |
headers['Content-Type'] = 'multipart/x-mixed-replace;boundary="socketio"'; | |
headers['Connection'] = 'keep-alive'; | |
// headers['Connection'] = 'close'; | |
res.useChunkedEncodingByDefault = false; | |
res.shouldKeepAlive = true; | |
res.writeHead(200, headers); | |
res.write("--socketio\n"); | |
var count = 10; | |
function write() { | |
if (count-- == 0) { | |
console.log("close") | |
res.end(); | |
return; | |
} | |
var message = Date.now() + " " + count; | |
console.log("write", message); | |
res.write("Content-Type: text/plain\n\n"); | |
res.write(message + "\n"); | |
res.write("--socketio\n"); | |
setTimeout(write, 500); | |
} | |
write(); | |
} | |
else { | |
res.writeHead(200, {"Content-Type": "text/html"}); | |
res.end(index); | |
} | |
}).listen(/*process.env.C9_PORT || */6666); | |
var httpProxy = require('http-proxy'); | |
//httpProxy.createServer(6666, 'localhost').listen(6060); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment