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
b6227021
Commit
b6227021
authored
Aug 02, 2010
by
Marak Squires
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated demo
parent
2f265a23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
README.md
README.md
+1
-0
demo.js
demo.js
+10
-12
No files found.
README.md
View file @
b6227021
...
@@ -63,6 +63,7 @@ see the [demo](http://github.com/nodejitsu/node-http-proxy/blob/master/demo.js)
...
@@ -63,6 +63,7 @@ see the [demo](http://github.com/nodejitsu/node-http-proxy/blob/master/demo.js)
res.write('request successfully proxied!' + '
\n
' + JSON.stringify(req.headers, true, 2));
res.write('request successfully proxied!' + '
\n
' + JSON.stringify(req.headers, true, 2));
res.end();
res.end();
}).listen(9000);
}).listen(9000);
</pre>
</pre>
### Why doesn't node-http-proxy have more advanced features like x, y, or z?
### Why doesn't node-http-proxy have more advanced features like x, y, or z?
...
...
demo.js
View file @
b6227021
...
@@ -39,11 +39,12 @@ var welcome = '\
...
@@ -39,11 +39,12 @@ var welcome = '\
# # # # # # # # #### # # #
\n
'
;
# # # # # # # # #### # # #
\n
'
;
sys
.
puts
(
welcome
.
rainbow
.
bold
);
sys
.
puts
(
welcome
.
rainbow
.
bold
);
// create regular http proxy server
/****** basic http proxy server ******/
httpProxy
.
createServer
(
'
localhost
'
,
9000
).
listen
(
8000
);
httpProxy
.
createServer
(
'
localhost
'
,
9000
).
listen
(
8000
);
sys
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8000
'
.
yellow
);
sys
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8000
'
.
yellow
);
/
/ http proxy server with latency
/
****** http proxy server with latency******/
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
){
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
){
setTimeout
(
function
(){
setTimeout
(
function
(){
proxy
.
proxyRequest
(
'
localhost
'
,
9000
,
req
,
res
);
proxy
.
proxyRequest
(
'
localhost
'
,
9000
,
req
,
res
);
...
@@ -51,21 +52,18 @@ httpProxy.createServer(function (req, res, proxy){
...
@@ -51,21 +52,18 @@ httpProxy.createServer(function (req, res, proxy){
}).
listen
(
8001
);
}).
listen
(
8001
);
sys
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8001
'
.
yellow
+
'
with latency
'
.
magenta
.
underline
);
sys
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8001
'
.
yellow
+
'
with latency
'
.
magenta
.
underline
);
/****** http server with proxyRequest handler and latency******/
// http proxy server with latency
http
.
createServer
(
function
(
req
,
res
){
http
.
createServer
(
function
(
req
,
res
){
var
proxy
=
new
httpProxy
.
HttpProxy
;
proxy
.
watch
(
req
,
res
);
setTimeout
(
function
(){
setTimeout
(
function
(){
var
proxy
=
new
httpProxy
.
HttpProxy
;
proxy
.
watch
(
req
,
res
);
proxy
.
proxyRequest
(
'
localhost
'
,
9000
,
req
,
res
);
proxy
.
proxyRequest
(
'
localhost
'
,
9000
,
req
,
res
);
},
200
);
},
200
)
}).
listen
(
8002
);
}).
listen
(
8002
);
sys
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8002
'
.
yellow
+
'
with latency
'
.
magenta
.
underline
);
sys
.
puts
(
'
http server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8002
'
.
yellow
+
'
with proxyRequest handler
'
.
cyan
.
underline
+
'
and latency
'
.
magenta
);
/
/ create regular http server
/
****** regular http server ******/
http
.
createServer
(
function
(
req
,
res
){
http
.
createServer
(
function
(
req
,
res
){
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
write
(
'
request successfully proxied:
'
+
req
.
url
+
'
\n
'
+
JSON
.
stringify
(
req
.
headers
,
true
,
2
));
res
.
write
(
'
request successfully proxied:
'
+
req
.
url
+
'
\n
'
+
JSON
.
stringify
(
req
.
headers
,
true
,
2
));
...
...
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