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
13eaec55
Commit
13eaec55
authored
Sep 10, 2011
by
indexzero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[doc] Updated examples
parent
2cd8256c
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
49 additions
and
56 deletions
+49
-56
examples/helpers/store.js
examples/helpers/store.js
+3
-6
examples/http/basic-proxy.js
examples/http/basic-proxy.js
+11
-10
examples/http/concurrent-proxy.js
examples/http/concurrent-proxy.js
+12
-11
examples/http/custom-proxy-error.js
examples/http/custom-proxy-error.js
+2
-7
examples/http/forward-proxy.js
examples/http/forward-proxy.js
+2
-2
examples/http/latent-proxy.js
examples/http/latent-proxy.js
+2
-2
examples/http/proxy-https-to-http.js
examples/http/proxy-https-to-http.js
+1
-1
examples/http/proxy-https-to-https.js
examples/http/proxy-https-to-https.js
+1
-1
examples/http/proxy-table.js
examples/http/proxy-table.js
+1
-1
examples/http/standalone-proxy.js
examples/http/standalone-proxy.js
+2
-2
examples/middleware/gzip-middleware.js
examples/middleware/gzip-middleware.js
+1
-1
examples/middleware/jsonp-middleware.js
examples/middleware/jsonp-middleware.js
+1
-1
examples/middleware/url-middleware.js
examples/middleware/url-middleware.js
+1
-1
examples/middleware/url-middleware2.js
examples/middleware/url-middleware2.js
+5
-6
examples/websocket/latent-websocket-proxy.js
examples/websocket/latent-websocket-proxy.js
+2
-2
examples/websocket/standalone-websocket-proxy.js
examples/websocket/standalone-websocket-proxy.js
+1
-1
examples/websocket/websocket-proxy.js
examples/websocket/websocket-proxy.js
+1
-1
No files found.
examples/helpers/store.js
View file @
13eaec55
module
.
exports
=
Store
//
// just to make these example a little bit interesting,
// make a little key value store with an http interface
...
...
@@ -20,12 +19,10 @@ module.exports = Store
//
// TODO: cached map-reduce views and auto-magic sharding.
//
var
Store
=
module
.
exports
=
function
Store
()
{
this
.
store
=
{};
};
function
Store
()
{
this
.
store
=
{}
}
Store
.
prototype
=
{
get
:
function
(
key
)
{
return
this
.
store
[
key
]
...
...
examples/http/basic-proxy.js
View file @
13eaec55
...
...
@@ -27,16 +27,17 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
// ascii art from http://github.com/marak/asciimo
var
welcome
=
'
\
# # ##### ##### ##### ##### ##### #### # # # #
\n\
# # # # # # # # # # # # # # # #
\n\
###### # # # # ##### # # # # # # ## #
\n\
# # # # ##### ##### ##### # # ## #
\n\
# # # # # # # # # # # # #
\n\
# # # # # # # # #### # # #
\n
'
;
httpProxy
=
require
(
'
../../lib/node-http-proxy
'
);
var
welcome
=
[
'
# # ##### ##### ##### ##### ##### #### # # # #
'
,
'
# # # # # # # # # # # # # # # #
'
,
'
###### # # # # ##### # # # # # # ## #
'
,
'
# # # # ##### ##### ##### # # ## #
'
,
'
# # # # # # # # # # # # #
'
,
'
# # # # # # # # #### # # #
'
].
join
(
'
\n
'
);
util
.
puts
(
welcome
.
rainbow
.
bold
);
//
...
...
examples/http/concurrent-proxy.js
View file @
13eaec55
...
...
@@ -27,7 +27,7 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Basic Http Proxy Server
...
...
@@ -42,23 +42,24 @@ httpProxy.createServer(9000, 'localhost').listen(8000);
//
var
connections
=
[]
,
go
var
connections
=
[]
,
go
;
http
.
createServer
(
function
(
req
,
res
)
{
connections
.
push
(
function
(){
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
+
'
,
'
)
});
process
.
stdout
.
write
(
connections
.
length
+
'
,
'
);
if
(
connections
.
length
>
110
||
go
)
{
go
=
true
while
(
connections
.
length
)
connections
.
shift
()()
go
=
true
;
while
(
connections
.
length
)
{
connections
.
shift
()();
}
}
}).
listen
(
9000
);
util
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8000
'
.
yellow
);
...
...
examples/http/custom-proxy-error.js
View file @
13eaec55
...
...
@@ -27,17 +27,12 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Http Proxy Server with Latency
//
var
server
=
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
)
{
proxy
.
proxyRequest
(
req
,
res
,
{
port
:
9000
,
host
:
'
localhost
'
});
})
var
server
=
httpProxy
.
createServer
(
9000
,
'
localhost
'
);
//
// Tell the server to listen on port 8002
...
...
examples/http/forward-proxy.js
View file @
13eaec55
...
...
@@ -27,7 +27,7 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Setup proxy server with forwarding
...
...
examples/http/latent-proxy.js
View file @
13eaec55
...
...
@@ -27,13 +27,13 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Http Proxy Server with Latency
//
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
)
{
var
buffer
=
p
roxy
.
buffer
(
req
);
var
buffer
=
httpP
roxy
.
buffer
(
req
);
setTimeout
(
function
()
{
proxy
.
proxyRequest
(
req
,
res
,
{
port
:
9000
,
...
...
examples/http/proxy-https-to-http.js
View file @
13eaec55
...
...
@@ -28,7 +28,7 @@ var https = require('https'),
http
=
require
(
'
http
'
),
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
),
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
),
helpers
=
require
(
'
./../test/helpers
'
);
var
opts
=
helpers
.
loadHttps
();
...
...
examples/http/proxy-https-to-https.js
View file @
13eaec55
...
...
@@ -28,7 +28,7 @@ var https = require('https'),
http
=
require
(
'
http
'
),
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
),
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
),
helpers
=
require
(
'
./../test/helpers
'
);
var
opts
=
helpers
.
loadHttps
();
...
...
examples/http/proxy-table.js
View file @
13eaec55
...
...
@@ -27,7 +27,7 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Http Proxy Server with Proxy Table
...
...
examples/http/standalone-proxy.js
View file @
13eaec55
...
...
@@ -27,14 +27,14 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Http Server with proxyRequest Handler and Latency
//
var
proxy
=
new
httpProxy
.
HttpProxy
();
http
.
createServer
(
function
(
req
,
res
)
{
var
buffer
=
p
roxy
.
buffer
(
req
);
var
buffer
=
httpP
roxy
.
buffer
(
req
);
setTimeout
(
function
()
{
proxy
.
proxyRequest
(
req
,
res
,
{
port
:
9000
,
...
...
examples/middleware/gzip-middleware.js
View file @
13eaec55
...
...
@@ -27,7 +27,7 @@
var
util
=
require
(
'
util
'
),
colors
=
require
(
'
colors
'
),
http
=
require
(
'
http
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
//
// Basic Http Proxy Server
...
...
examples/middleware/jsonp-middleware.js
View file @
13eaec55
examples/middleware/url-middleware.js
View file @
13eaec55
examples/middleware/url-middleware2.js
View file @
13eaec55
...
...
@@ -19,12 +19,11 @@ httpProxy.createServer(
//
// Target Http Server (to listen for requests on 'localhost')
//
http
.
createServer
(
function
(
req
,
res
)
{
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
);
}).
listen
(
9000
);
// And finally, some colored startup output.
util
.
puts
(
'
http proxy server
'
.
blue
+
'
started
'
.
green
.
bold
+
'
on port
'
.
blue
+
'
8000
'
.
yellow
);
...
...
examples/websocket/latent-websocket-proxy.js
View file @
13eaec55
...
...
@@ -28,7 +28,7 @@ var sys = require('sys'),
http
=
require
(
'
http
'
),
colors
=
require
(
'
colors
'
),
websocket
=
require
(
'
./../vendor/websocket
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
try
{
var
utils
=
require
(
'
socket.io/lib/socket.io/utils
'
),
...
...
@@ -80,7 +80,7 @@ var proxyServer = http.createServer(function (req, res) {
// WebSocket requests as well.
//
proxyServer
.
on
(
'
upgrade
'
,
function
(
req
,
socket
,
head
)
{
var
buffer
=
p
roxy
.
buffer
(
socket
);
var
buffer
=
httpP
roxy
.
buffer
(
socket
);
setTimeout
(
function
()
{
proxy
.
proxyWebSocketRequest
(
req
,
socket
,
head
,
{
...
...
examples/websocket/standalone-websocket-proxy.js
View file @
13eaec55
...
...
@@ -28,7 +28,7 @@ var sys = require('sys'),
http
=
require
(
'
http
'
),
colors
=
require
(
'
colors
'
),
websocket
=
require
(
'
./../vendor/websocket
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
try
{
var
utils
=
require
(
'
socket.io/lib/socket.io/utils
'
),
...
...
examples/websocket/websocket-proxy.js
View file @
13eaec55
...
...
@@ -28,7 +28,7 @@ var sys = require('sys'),
http
=
require
(
'
http
'
),
colors
=
require
(
'
colors
'
),
websocket
=
require
(
'
./../vendor/websocket
'
),
httpProxy
=
require
(
'
./../lib/node-http-proxy
'
);
httpProxy
=
require
(
'
.
.
/../lib/node-http-proxy
'
);
try
{
var
utils
=
require
(
'
socket.io/lib/socket.io/utils
'
),
...
...
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