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
db10c4af
Commit
db10c4af
authored
Aug 28, 2011
by
indexzero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Updates for readability
parent
1389b706
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
13 deletions
+29
-13
test/helpers.js
test/helpers.js
+29
-13
No files found.
test/helpers.js
View file @
db10c4af
...
@@ -59,7 +59,10 @@ TestRunner.prototype.assertProxied = function (host, proxyPort, port, createProx
...
@@ -59,7 +59,10 @@ TestRunner.prototype.assertProxied = function (host, proxyPort, port, createProx
var
test
=
{
var
test
=
{
topic
:
function
()
{
topic
:
function
()
{
var
that
=
this
,
options
=
{
var
that
=
this
,
options
;
options
=
{
method
:
'
GET
'
,
method
:
'
GET
'
,
uri
:
self
.
protocol
+
'
://localhost:
'
+
proxyPort
,
uri
:
self
.
protocol
+
'
://localhost:
'
+
proxyPort
,
headers
:
{
headers
:
{
...
@@ -172,9 +175,9 @@ TestRunner.prototype.webSocketTestWithTable = function (options) {
...
@@ -172,9 +175,9 @@ TestRunner.prototype.webSocketTestWithTable = function (options) {
options
.
onListen
(
socket
);
options
.
onListen
(
socket
);
}
}
self
.
startProxyServerWithTable
(
self
.
startProxyServerWithTable
(
options
.
ports
.
proxy
,
options
.
ports
.
proxy
,
{
router
:
options
.
router
},
{
router
:
options
.
router
},
function
(
err
,
proxy
)
{
function
(
err
,
proxy
)
{
if
(
options
.
onServer
)
{
options
.
onServer
(
proxy
)
}
if
(
options
.
onServer
)
{
options
.
onServer
(
proxy
)
}
...
@@ -213,7 +216,10 @@ TestRunner.prototype.startProxyServer = function (port, targetPort, host, callba
...
@@ -213,7 +216,10 @@ TestRunner.prototype.startProxyServer = function (port, targetPort, host, callba
//
//
TestRunner
.
prototype
.
startLatentProxyServer
=
function
(
port
,
targetPort
,
host
,
latency
,
callback
)
{
TestRunner
.
prototype
.
startLatentProxyServer
=
function
(
port
,
targetPort
,
host
,
latency
,
callback
)
{
// Initialize the nodeProxy and start proxying the request
// Initialize the nodeProxy and start proxying the request
var
that
=
this
,
proxyServer
=
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
)
{
var
that
=
this
,
proxyServer
;
proxyServer
=
httpProxy
.
createServer
(
function
(
req
,
res
,
proxy
)
{
var
buffer
=
proxy
.
buffer
(
req
);
var
buffer
=
proxy
.
buffer
(
req
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
...
@@ -235,7 +241,9 @@ TestRunner.prototype.startLatentProxyServer = function (port, targetPort, host,
...
@@ -235,7 +241,9 @@ TestRunner.prototype.startLatentProxyServer = function (port, targetPort, host,
// Creates the reverse proxy server with a ProxyTable
// Creates the reverse proxy server with a ProxyTable
//
//
TestRunner
.
prototype
.
startProxyServerWithTable
=
function
(
port
,
options
,
callback
)
{
TestRunner
.
prototype
.
startProxyServerWithTable
=
function
(
port
,
options
,
callback
)
{
var
that
=
this
,
proxyServer
=
httpProxy
.
createServer
(
merge
({},
options
,
this
.
options
));
var
that
=
this
,
proxyServer
=
httpProxy
.
createServer
(
merge
({},
options
,
this
.
options
));
proxyServer
.
listen
(
port
,
function
()
{
proxyServer
.
listen
(
port
,
function
()
{
that
.
testServers
.
push
(
proxyServer
);
that
.
testServers
.
push
(
proxyServer
);
callback
();
callback
();
...
@@ -248,10 +256,12 @@ TestRunner.prototype.startProxyServerWithTable = function (port, options, callba
...
@@ -248,10 +256,12 @@ TestRunner.prototype.startProxyServerWithTable = function (port, options, callba
// Creates a latent reverse proxy server using a ProxyTable
// Creates a latent reverse proxy server using a ProxyTable
//
//
TestRunner
.
prototype
.
startProxyServerWithTableAndLatency
=
function
(
port
,
latency
,
options
,
callback
)
{
TestRunner
.
prototype
.
startProxyServerWithTableAndLatency
=
function
(
port
,
latency
,
options
,
callback
)
{
//
// Initialize the nodeProxy and start proxying the request
// Initialize the nodeProxy and start proxying the request
var
proxyServer
,
//
that
=
this
,
var
that
=
this
,
proxy
=
new
httpProxy
.
HttpProxy
(
merge
({},
options
,
that
.
options
));
proxy
=
new
httpProxy
.
HttpProxy
(
merge
({},
options
,
that
.
options
)),
proxyServer
;
var
handler
=
function
(
req
,
res
)
{
var
handler
=
function
(
req
,
res
)
{
var
buffer
=
proxy
.
buffer
(
req
);
var
buffer
=
proxy
.
buffer
(
req
);
...
@@ -263,8 +273,8 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
...
@@ -263,8 +273,8 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
};
};
proxyServer
=
that
.
options
.
https
proxyServer
=
that
.
options
.
https
?
https
.
createServer
(
that
.
options
.
https
,
handler
,
that
.
options
)
?
https
.
createServer
(
that
.
options
.
https
,
handler
,
that
.
options
)
:
http
.
createServer
(
handler
,
that
.
options
);
:
http
.
createServer
(
handler
,
that
.
options
);
proxyServer
.
listen
(
port
,
function
()
{
proxyServer
.
listen
(
port
,
function
()
{
that
.
testServers
.
push
(
proxyServer
);
that
.
testServers
.
push
(
proxyServer
);
...
@@ -278,7 +288,9 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
...
@@ -278,7 +288,9 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
// Creates proxy server forwarding to the specified options
// Creates proxy server forwarding to the specified options
//
//
TestRunner
.
prototype
.
startProxyServerWithForwarding
=
function
(
port
,
targetPort
,
host
,
options
,
callback
)
{
TestRunner
.
prototype
.
startProxyServerWithForwarding
=
function
(
port
,
targetPort
,
host
,
options
,
callback
)
{
var
that
=
this
,
proxyServer
=
httpProxy
.
createServer
(
targetPort
,
host
,
merge
({},
options
,
this
.
options
));
var
that
=
this
,
proxyServer
=
httpProxy
.
createServer
(
targetPort
,
host
,
merge
({},
options
,
this
.
options
));
proxyServer
.
listen
(
port
,
function
()
{
proxyServer
.
listen
(
port
,
function
()
{
that
.
testServers
.
push
(
proxyServer
);
that
.
testServers
.
push
(
proxyServer
);
callback
(
null
,
proxyServer
);
callback
(
null
,
proxyServer
);
...
@@ -289,7 +301,11 @@ TestRunner.prototype.startProxyServerWithForwarding = function (port, targetPort
...
@@ -289,7 +301,11 @@ TestRunner.prototype.startProxyServerWithForwarding = function (port, targetPort
// Creates the 'hellonode' server
// Creates the 'hellonode' server
//
//
TestRunner
.
prototype
.
startTargetServer
=
function
(
port
,
output
,
callback
)
{
TestRunner
.
prototype
.
startTargetServer
=
function
(
port
,
output
,
callback
)
{
var
that
=
this
,
targetServer
,
handler
=
function
(
req
,
res
)
{
var
that
=
this
,
targetServer
,
handler
;
handler
=
function
(
req
,
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
write
(
output
);
res
.
write
(
output
);
res
.
end
();
res
.
end
();
...
...
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