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
56003b52
Commit
56003b52
authored
Sep 16, 2010
by
Fedor Indutny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support of automatic websocket tunneling, added test for it
parent
cd78af5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
lib/node-http-proxy.js
lib/node-http-proxy.js
+14
-6
test/node-http-proxy-websocket-test.js
test/node-http-proxy-websocket-test.js
+4
-1
No files found.
lib/node-http-proxy.js
View file @
56003b52
...
@@ -60,9 +60,17 @@ exports.createServer = function () {
...
@@ -60,9 +60,17 @@ exports.createServer = function () {
}
}
});
});
// WebSocket support
// If callback is empty - tunnel websocket request automatically
server
.
on
(
'
update
'
,
function
()
{
if
(
!
callback
)
{
});
// WebSocket support
server
.
on
(
'
upgrade
'
,
function
(
req
,
socket
,
head
)
{
var
proxy
=
new
HttpProxy
(
req
,
socket
,
head
);
// Tunnel websocket requests too
proxy
.
proxyWebSocketRequest
(
port
,
host
);
});
}
return
server
;
return
server
;
};
};
...
@@ -325,12 +333,12 @@ HttpProxy.prototype = {
...
@@ -325,12 +333,12 @@ HttpProxy.prototype = {
request
.
end
();
request
.
end
();
socket
.
end
();
socket
.
end
();
}
}
// Catch socket errors
// Catch socket errors
socket
.
on
(
'
error
'
,
function
()
{
socket
.
on
(
'
error
'
,
function
()
{
request
.
end
();
request
.
end
();
});
});
// Remove data listener
// Remove data listener
request
.
socket
.
removeListener
(
'
data
'
,
t
);
request
.
socket
.
removeListener
(
'
data
'
,
t
);
});
});
...
@@ -344,7 +352,7 @@ HttpProxy.prototype = {
...
@@ -344,7 +352,7 @@ HttpProxy.prototype = {
}
}
self
.
unwatch
(
socket
);
self
.
unwatch
(
socket
);
});
});
// Request
// Request
function
onUpgrade
(
reverse_proxy
)
{
function
onUpgrade
(
reverse_proxy
)
{
...
...
test/node-http-proxy-websocket-test.js
View file @
56003b52
...
@@ -48,4 +48,7 @@ server.on('upgrade', function(req, socket, head) {
...
@@ -48,4 +48,7 @@ server.on('upgrade', function(req, socket, head) {
p
.
proxyWebSocketRequest
(
8080
,
'
localhost
'
);
p
.
proxyWebSocketRequest
(
8080
,
'
localhost
'
);
});
});
server
.
listen
(
80
);
server
.
listen
(
8000
);
httpProxy
.
createServer
(
8080
,
'
localhost
'
).
listen
(
8001
);
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