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
2fb5ffba
Commit
2fb5ffba
authored
Jul 26, 2010
by
Marak Squires
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started to flesh out simple demo based on tests
parent
d490b50a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
19 deletions
+60
-19
demo.js
demo.js
+60
-18
lib/asciimo.js
lib/asciimo.js
+0
-0
vendor/asciimo
vendor/asciimo
+0
-1
No files found.
demo.js
View file @
2fb5ffba
...
...
@@ -12,14 +12,53 @@ var vows = require('vows'),
assert
=
require
(
'
assert
'
),
http
=
require
(
'
http
'
);
require
.
paths
.
unshift
(
require
(
'
path
'
).
join
(
__dirname
,
'
../lib/
'
));
var
NodeProxy
=
require
(
'
./lib/node-proxy
'
).
NodeProxy
;
var
testServers
=
{};
sys
.
puts
(
'
node-http-proxy has started!
'
.
rainbow
);
// regular http server
http
.
createServer
(
function
(
req
,
res
){
// Initialize the nodeProxy and start proxying the request
var
proxy
=
new
(
NodeProxy
);
proxy
.
init
(
req
,
res
);
// lets proxy the request to another service
proxy
.
proxyRequest
(
'
localhost
'
,
'
8081
'
,
req
,
res
);
}).
listen
(
8080
);
sys
.
puts
(
'
started a http server on port 8080
'
.
green
)
// http server with latency
http
.
createServer
(
function
(
req
,
res
){
// Initialize the nodeProxy and start proxying the request
var
proxy
=
new
(
NodeProxy
);
proxy
.
init
(
req
,
res
);
// lets proxy the request to another service
setTimeout
(
function
(){
proxy
.
proxyRequest
(
'
localhost
'
,
'
8090
'
,
req
,
res
);
},
200
)
}).
listen
(
8081
);
sys
.
puts
(
'
started a http server with latency on port 8081
'
.
green
)
http
.
createServer
(
function
(
req
,
res
){
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
write
(
'
foo
'
);
res
.
end
();
}).
listen
(
8090
);
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;
var
NodeProxy
=
require
(
'
./lib/node-proxy
'
).
NodeProxy
;
var
testServers
=
{};
//
// Simple 'hello world' response for test purposes
...
...
@@ -30,19 +69,6 @@ var helloWorld = function(req, res) {
res.end();
};
//
// Creates the reverse proxy server
//
var
startProxyServer
=
function
(
server
,
port
,
proxy
)
{
var
proxyServer
=
http
.
createServer
(
function
(
req
,
res
){
// Initialize the nodeProxy and start proxying the request
proxy
.
init
(
req
,
res
);
proxy
.
proxyRequest
(
server
,
port
,
req
,
res
);
});
proxyServer
.
listen
(
8080
);
return
proxyServer
;
};
//
// Creates the reverse proxy server with a specified latency
...
...
@@ -90,6 +116,20 @@ var startTestWithLatency = function (proxy, port) {
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" : {
...
...
@@ -127,4 +167,6 @@ vows.describe('node-proxy').addBatch({
}
}
}
}).
export
(
module
);
\ No newline at end of file
}).export(module);
*/
\ No newline at end of file
lib/asciimo.js
deleted
100644 → 0
View file @
d490b50a
asciimo
@
00f324d5
Subproject commit 00f324d5e70a3c29321b48af04852e6b2b476d12
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