mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[examples] Updated examples to v0.7.x API.
This commit is contained in:
parent
24ef919495
commit
8fc8d966c4
@ -67,12 +67,14 @@ socket.on('connection', function (client) {
|
||||
//
|
||||
// Setup our server to proxy standard HTTP requests
|
||||
//
|
||||
var proxy = new httpProxy.HttpProxy();
|
||||
var proxyServer = http.createServer(function (req, res) {
|
||||
proxy.proxyRequest(req, res, {
|
||||
var proxy = new httpProxy.HttpProxy({
|
||||
target: {
|
||||
host: 'localhost',
|
||||
port: 8080
|
||||
})
|
||||
}
|
||||
});
|
||||
var proxyServer = http.createServer(function (req, res) {
|
||||
proxy.proxyRequest(req, res);
|
||||
});
|
||||
|
||||
//
|
||||
@ -83,11 +85,7 @@ proxyServer.on('upgrade', function (req, socket, head) {
|
||||
var buffer = httpProxy.buffer(socket);
|
||||
|
||||
setTimeout(function () {
|
||||
proxy.proxyWebSocketRequest(req, socket, head, {
|
||||
port: 8080,
|
||||
host: 'localhost',
|
||||
buffer: buffer
|
||||
});
|
||||
proxy.proxyWebSocketRequest(req, socket, head, buffer);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
@ -67,12 +67,14 @@ socket.on('connection', function (client) {
|
||||
//
|
||||
// Setup our server to proxy standard HTTP requests
|
||||
//
|
||||
var proxy = new httpProxy.HttpProxy();
|
||||
var proxyServer = http.createServer(function (req, res) {
|
||||
proxy.proxyRequest(req, res, {
|
||||
var proxy = new httpProxy.HttpProxy({
|
||||
target: {
|
||||
host: 'localhost',
|
||||
port: 8080
|
||||
})
|
||||
}
|
||||
});
|
||||
var proxyServer = http.createServer(function (req, res) {
|
||||
proxy.proxyRequest(req, res);
|
||||
});
|
||||
|
||||
//
|
||||
@ -80,10 +82,7 @@ var proxyServer = http.createServer(function (req, res) {
|
||||
// WebSocket requests as well.
|
||||
//
|
||||
proxyServer.on('upgrade', function (req, socket, head) {
|
||||
proxy.proxyWebSocketRequest(req, socket, head, {
|
||||
port: 8080,
|
||||
host: 'localhost'
|
||||
});
|
||||
proxy.proxyWebSocketRequest(req, socket, head);
|
||||
});
|
||||
|
||||
proxyServer.listen(8081);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user