Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
node-http-proxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
node-http-proxy
Commits
994f7481
Commit
994f7481
authored
Jul 27, 2010
by
Marak Squires
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fleshing out demo
parent
2fb5ffba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
117 deletions
+0
-117
demo.js
demo.js
+0
-117
No files found.
demo.js
View file @
994f7481
...
...
@@ -53,120 +53,3 @@ sys.puts('started another http server on port 8090'.green)
sys
.
puts
(
'
to test the proxy server, request http://localhost:8080/ in your browser.
'
);
sys
.
puts
(
'
your request will proxy to the server running on port 8081
'
);
/*
return;
//
// Simple 'hello world' response for test purposes
//
var helloWorld = function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello world')
res.end();
};
//
// Creates the reverse proxy server with a specified latency
//
var startLatentProxyServer = function (server, port, proxy, latency) {
var proxyServer = http.createServer(function (req, res){
// Initialize the nodeProxy and start proxying the request
proxy.init(req, res);
setTimeout(function () {
proxy.proxyRequest(server, port, req, res);
}, latency);
});
proxyServer.listen(8081);
return proxyServer;
};
//
// Creates the 'hellonode' server
//
var startTargetServer = function (port) {
var targetServer = http.createServer(function (req, res) {
helloWorld(req, res);
})
targetServer.listen(port);
return targetServer;
};
//
// The default test bootstrapper with no latency
//
var startTest = function (proxy, port) {
testServers.noLatency = [];
testServers.noLatency.push(startProxyServer('127.0.0.1', port, proxy));
testServers.noLatency.push(startTargetServer(port));
};
//
// The test bootstrapper with some latency
//
var startTestWithLatency = function (proxy, port) {
testServers.latency = [];
testServers.latency.push(startLatentProxyServer('127.0.0.1', port, proxy, 2000));
testServers.latency.push(startTargetServer(port));
};
sys.puts('node-http-proxy has started!'.green);
// start the http-proxy
var proxy = new (NodeProxy);
startTest(proxy, 8082);
// start a second http server (which we will reverse proxy our requests to)
return;
vows.describe('node-proxy').addBatch({
"When an incoming request is proxied to the helloNode server" : {
"with no latency" : {
topic: function () {
var proxy = new (NodeProxy);
startTest(proxy, 8082);
proxy.emitter.addListener('end', this.callback);
var client = http.createClient(8080, '127.0.0.1');
var request = client.request('GET', '/');
request.end();
},
"it should received 'hello world'": function (err, body) {
assert.equal(body, 'hello world');
testServers.noLatency.forEach(function (server) {
server.close();
})
}
},
"with latency": {
topic: function () {
var proxy = new (NodeProxy);
startTestWithLatency(proxy, 8083);
proxy.emitter.addListener('end', this.callback);
var client = http.createClient(8081, '127.0.0.1');
var request = client.request('GET', '/');
request.end();
},
"it should receive 'hello world'": function (err, body) {
assert.equal(body, 'hello world');
testServers.latency.forEach(function (server) {
server.close();
})
}
}
}
}).export(module);
*/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment