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
7976de11
Commit
7976de11
authored
Jul 25, 2011
by
Dominic Tarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support old (port,host) and (options) style when using middlewares
parent
c773eede
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
lib/node-http-proxy.js
lib/node-http-proxy.js
+26
-19
No files found.
lib/node-http-proxy.js
View file @
7976de11
...
@@ -112,6 +112,7 @@ exports.getMaxSockets = function () {
...
@@ -112,6 +112,7 @@ exports.getMaxSockets = function () {
exports
.
setMaxSockets
=
function
(
value
)
{
exports
.
setMaxSockets
=
function
(
value
)
{
maxSockets
=
value
;
maxSockets
=
value
;
};
};
//
//
// stack
// stack
// adapted from https://github.com/creationix/stack
// adapted from https://github.com/creationix/stack
...
@@ -122,15 +123,16 @@ function stack (middlewares, proxy) {
...
@@ -122,15 +123,16 @@ function stack (middlewares, proxy) {
middlewares
.
reverse
().
forEach
(
function
(
layer
)
{
middlewares
.
reverse
().
forEach
(
function
(
layer
)
{
var
child
=
handle
;
var
child
=
handle
;
var
next
=
function
(
err
)
{
if
(
err
)
{
throw
err
;
//return error(req, res, err);
}
child
(
req
,
res
);
}
next
.
__proto__
=
proxy
;
handle
=
function
(
req
,
res
)
{
handle
=
function
(
req
,
res
)
{
var
next
=
function
(
err
)
{
if
(
err
)
{
throw
err
;
//TODO: figure out where to send errors.
//return error(req, res, err);
}
child
(
req
,
res
);
}
next
.
__proto__
=
proxy
;
layer
(
req
,
res
,
next
);
layer
(
req
,
res
,
next
);
};
};
});
});
...
@@ -167,11 +169,6 @@ exports.createServer = function () {
...
@@ -167,11 +169,6 @@ exports.createServer = function () {
var
proxy
=
new
HttpProxy
(
options
);
var
proxy
=
new
HttpProxy
(
options
);
if
(
middleware
.
length
)
//handler = callback = middleware.shift()
//else if (middleware.length)
handler
=
callback
=
stack
(
middleware
,
proxy
);
if
(
port
&&
host
)
{
if
(
port
&&
host
)
{
//
//
// If we have a target host and port for the request
// If we have a target host and port for the request
...
@@ -183,6 +180,8 @@ exports.createServer = function () {
...
@@ -183,6 +180,8 @@ exports.createServer = function () {
host
:
host
host
:
host
});
});
}
}
if
(
middleware
.
length
)
middleware
.
push
(
handler
)
}
}
else
if
(
proxy
.
proxyTable
)
{
else
if
(
proxy
.
proxyTable
)
{
//
//
...
@@ -192,13 +191,21 @@ exports.createServer = function () {
...
@@ -192,13 +191,21 @@ exports.createServer = function () {
handler
=
function
(
req
,
res
)
{
handler
=
function
(
req
,
res
)
{
proxy
.
proxyRequest
(
req
,
res
);
proxy
.
proxyRequest
(
req
,
res
);
}
}
if
(
middleware
.
length
)
middleware
.
push
(
handler
)
}
}
else
if
(
!
handler
)
{
//
if
(
middleware
.
length
)
// Otherwise this server is improperly configured.
//handler = callback = middleware.shift()
//
//else if (middleware.length)
throw
new
Error
(
'
Cannot proxy without port, host, or router.
'
)
handler
=
callback
=
stack
(
middleware
,
proxy
);
}
if
(
!
handler
)
{
//
// Otherwise this server is improperly configured.
//
throw
new
Error
(
'
Cannot proxy without port, host, or router.
'
)
}
server
=
options
.
https
server
=
options
.
https
?
https
.
createServer
(
options
.
https
,
handler
)
?
https
.
createServer
(
options
.
https
,
handler
)
...
...
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