diff --git a/examples/concurrent-proxy.js b/examples/concurrent-proxy.js deleted file mode 100644 index 0d1889f89..000000000 --- a/examples/concurrent-proxy.js +++ /dev/null @@ -1,36 +0,0 @@ -var http = require('http'), - httpProxy = require('../lib/http-proxy'); - -var connections = [], - go; - - -// -// Target Http Server -// -// to check apparent problems with concurrent connections -// make a server which only responds when there is a given nubmer on connections -// -http.createServer(function (req, res) { - connections.push(function () { - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); - res.end(); - }); - - process.stdout.write(connections.length + ', '); - - if (connections.length > 10 || go) { - go = true; - while (connections.length) { - connections.shift()(); - } - } -}).listen(9000); -console.log("Web server listening on port 9000"); - -// -// Basic Http Proxy Server -// -httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); -console.log("Proxy server listening on port 8000"); \ No newline at end of file diff --git a/examples/error-handling.js b/examples/error-handling.js deleted file mode 100644 index 76a09d955..000000000 --- a/examples/error-handling.js +++ /dev/null @@ -1,33 +0,0 @@ -var httpProxy = require('../lib/http-proxy'), - http = require('http'); -/* - * Create your proxy server - */ -var proxy = httpProxy.createProxyServer({target:'http://localhost:30404', ws:true}); - -var proxyServer = http.createServer(requestHandler); - -function requestHandler(req, res) { - // Pass a callback to the web proxy method - // and catch the error there. - proxy.web(req, res, function (err) { - // Now you can get the err - // and handle it by your self - // if (err) throw err; - res.writeHead(502); - res.end("There was an error proxying your request"); - }); - - // In a websocket request case - req.on('upgrade', function (req, socket, head) { - proxy.ws(req, socket, head, function (err) { - // Now you can get the err - // and handle it by your self - // if (err) throw err; - socket.close(); - }) - }) -} - -console.log("Proxy server is listening on port 8000"); -proxyServer.listen(8000) \ No newline at end of file diff --git a/examples/forward-proxy.js b/examples/forward-proxy.js deleted file mode 100644 index 4cb516f50..000000000 --- a/examples/forward-proxy.js +++ /dev/null @@ -1,33 +0,0 @@ -var http = require('http'), - httpProxy = require('../lib/http-proxy'); - -// -// Target Http Server -// -http.createServer(function (req, res) { - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); - res.end(); -}).listen(9000); -console.log("Web server listening on port 9000"); - -// -// Target Http Forwarding Server -// -http.createServer(function (req, res) { - console.log('Receiving forward for: ' + req.url); - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); - res.end(); -}).listen(9001); - -// -// Basic Http Proxy Server -// Forward example: send requests without care about response -// -httpProxy.createServer({ - target: 'http://localhost:9000', - forward: 'http://localhost:9001' -}).listen(8000) -console.log("Proxy server listening on port 8000"); - diff --git a/examples/https-secure.js b/examples/https-secure.js deleted file mode 100644 index 83b87eb7c..000000000 --- a/examples/https-secure.js +++ /dev/null @@ -1,16 +0,0 @@ -var httpProxy = require('../lib/http-proxy'), - https = require('https'); -/* - * Create your proxy server pointing to a secure domain - * Enable ssl validation - */ -var options = { - target : 'https://google.com', - agent : https.globalAgent, - headers: {host: 'google.com'} -}; - -var proxyServer = httpProxy.createProxyServer(options); -console.log("Proxy server listening on port 8000"); -proxyServer.listen(8000); - diff --git a/examples/https.js b/examples/https.js deleted file mode 100644 index 364d7cb2f..000000000 --- a/examples/https.js +++ /dev/null @@ -1,13 +0,0 @@ -var httpProxy = require('../lib/http-proxy'); -/* - * Create your proxy server pointing to a secure domain - */ -var options = { - target:'https://google.com', - headers: {host: 'google.com'} -}; - -var proxyServer = httpProxy.createProxyServer(options); -console.log("Proxy server listening on port 8000"); -proxyServer.listen(8000); - diff --git a/examples/stand-alone.js b/examples/stand-alone.js deleted file mode 100644 index e5239c460..000000000 --- a/examples/stand-alone.js +++ /dev/null @@ -1,17 +0,0 @@ -var http = require('http'), - httpProxy = require('../lib/http-proxy'); -// -// Create your proxy server -// -console.log("Proxy server listening on port 8000"); -httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); - -// -// Create your target server -// -console.log("Web server listening on port 9000"); -http.createServer(function (req, res) { - res.writeHead(200, { 'Content-Type': 'text/plain' }); - res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2)); - res.end(); -}).listen(9000); \ No newline at end of file