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
5575bcf6
Commit
5575bcf6
authored
Sep 08, 2011
by
indexzero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[minor] Remove commented out debug statements.
parent
558a8a4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
63 deletions
+48
-63
lib/node-http-proxy.js
lib/node-http-proxy.js
+48
-63
No files found.
lib/node-http-proxy.js
View file @
5575bcf6
...
...
@@ -349,6 +349,7 @@ HttpProxy.prototype.buffer = function (obj) {
this
.
resume
=
function
()
{
console
.
error
(
"
Cannot resume buffer after destroying it.
"
);
};
onData
=
onEnd
=
events
=
obj
=
null
;
},
resume
:
function
()
{
...
...
@@ -414,9 +415,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
try
{
res
.
writeHead
(
404
);
res
.
end
();
}
catch
(
er
)
{
}
catch
(
er
)
{
console
.
error
(
"
res.writeHead/res.end error: %s
"
,
er
.
message
);
}
return
;
}
...
...
@@ -492,11 +495,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
}
}
try
{
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
);
}
try
{
res
.
end
()
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
}
outgoing
=
{
...
...
@@ -524,11 +524,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
// `response.statusCode === 304`: No 'data' event and no 'end'
if
(
response
.
statusCode
===
304
)
{
try
{
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
try
{
res
.
end
()
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
return
;
}
...
...
@@ -540,26 +537,24 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if
(
req
.
method
!==
'
HEAD
'
&&
res
.
writable
)
{
try
{
var
flushed
=
res
.
write
(
chunk
);
}
catch
(
er
)
{
}
catch
(
er
)
{
console
.
error
(
"
res.write error: %s
"
,
er
.
message
);
try
{
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
);
}
try
{
res
.
end
()
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
return
;
}
}
if
(
!
flushed
)
{
//console.error('backpressure 554');
response
.
pause
();
res
.
once
(
'
drain
'
,
function
()
{
try
{
response
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
response.resume error: %s
"
,
er
.
message
);
}
try
{
response
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
response.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
res
.
emit
(
'
drain
'
);
},
100
);
...
...
@@ -574,11 +569,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
response
.
on
(
'
end
'
,
function
()
{
if
(
!
errState
)
{
reverseProxy
.
removeListener
(
'
error
'
,
proxyError
);
try
{
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
);
}
try
{
res
.
end
()
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
// Emit the `end` event now that we have completed proxying
self
.
emit
(
'
end
'
,
req
,
res
);
...
...
@@ -595,15 +588,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if
(
!
errState
)
{
var
flushed
=
reverseProxy
.
write
(
chunk
);
if
(
!
flushed
)
{
//console.error('backpressure 594');
req
.
pause
();
reverseProxy
.
once
(
'
drain
'
,
function
()
{
try
{
req
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
);
}
try
{
req
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
reverseProxy
.
emit
(
'
drain
'
);
},
100
);
...
...
@@ -625,7 +616,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
if
(
options
.
buffer
)
{
if
(
!
errState
)
{
options
.
buffer
.
resume
();
}
else
{
}
else
{
options
.
buffer
.
destroy
();
}
}
...
...
@@ -677,15 +669,13 @@ HttpProxy.prototype._forwardRequest = function (req) {
req
.
on
(
'
data
'
,
function
(
chunk
)
{
var
flushed
=
forwardProxy
.
write
(
chunk
);
if
(
!
flushed
)
{
//console.error('backpressure 672');
req
.
pause
();
forwardProxy
.
once
(
'
drain
'
,
function
()
{
try
{
req
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
);
}
try
{
req
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
forwardProxy
.
emit
(
'
drain
'
);
},
100
);
...
...
@@ -786,21 +776,19 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
self
.
emit
(
'
websocket:outgoing
'
,
req
,
socket
,
head
,
data
);
var
flushed
=
reverseProxy
.
incoming
.
socket
.
write
(
data
);
if
(
!
flushed
)
{
//console.error('backpressure 777');
proxySocket
.
pause
();
reverseProxy
.
incoming
.
socket
.
once
(
'
drain
'
,
function
()
{
try
{
proxySocket
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
proxySocket.resume error: %s
"
,
er
.
message
);
}
try
{
proxySocket
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
proxySocket.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
reverseProxy
.
incoming
.
socket
.
emit
(
'
drain
'
);
},
100
);
}
}
catch
(
e
)
{
catch
(
e
x
)
{
detach
();
reverseProxy
.
incoming
.
socket
.
end
();
proxySocket
.
end
();
...
...
@@ -817,21 +805,19 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
self
.
emit
(
'
websocket:incoming
'
,
reverseProxy
,
reverseProxy
.
incoming
,
head
,
data
);
var
flushed
=
proxySocket
.
write
(
data
);
if
(
!
flushed
)
{
//console.error('backpressure 804');
reverseProxy
.
incoming
.
socket
.
pause
();
proxySocket
.
once
(
'
drain
'
,
function
()
{
try
{
reverseProxy
.
incoming
.
socket
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
reverseProxy.incoming.socket.resume error: %s
"
,
er
.
message
);
}
try
{
reverseProxy
.
incoming
.
socket
.
resume
()
}
catch
(
ex
)
{
console
.
error
(
"
reverseProxy.incoming.socket.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
proxySocket
.
emit
(
'
drain
'
);
},
100
);
}
}
catch
(
e
)
{
catch
(
e
x
)
{
detach
();
proxySocket
.
end
();
socket
.
end
();
...
...
@@ -991,15 +977,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
socket
.
write
(
sdata
);
var
flushed
=
socket
.
write
(
data
);
if
(
!
flushed
)
{
//console.error('backpressure 974');
reverseProxy
.
socket
.
pause
();
socket
.
once
(
'
drain
'
,
function
()
{
try
{
reverseProxy
.
socket
.
resume
();
}
catch
(
er
)
{
console
.
error
(
"
reverseProxy.socket.resume error: %s
"
,
er
.
message
);
}
try
{
reverseProxy
.
socket
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
reverseProxy.socket.resume error: %s
"
,
er
.
message
)
}
});
setTimeout
(
function
()
{
socket
.
emit
(
'
drain
'
);
},
100
);
...
...
@@ -1007,7 +991,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
}
catch
(
ex
)
{
proxyError
(
ex
)
proxyError
(
ex
)
;
}
// Catch socket errors
...
...
@@ -1034,7 +1018,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
if
(
options
.
buffer
)
{
if
(
!
errState
)
{
options
.
buffer
.
resume
();
}
else
{
}
else
{
options
.
buffer
.
destroy
();
}
}
...
...
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