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
e1c41d06
Commit
e1c41d06
authored
Aug 28, 2011
by
indexzero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] Add guards to every throw-able res.end call
parent
de4a6fe8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
lib/node-http-proxy/http-proxy.js
lib/node-http-proxy/http-proxy.js
+12
-6
No files found.
lib/node-http-proxy/http-proxy.js
View file @
e1c41d06
...
@@ -178,7 +178,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
...
@@ -178,7 +178,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
}
}
}
}
res
.
end
();
try
{
res
.
end
()
}
catch
(
ex
)
{
console
.
error
(
"
res.end error: %s
"
,
ex
.
message
)
}
}
}
//
//
...
@@ -209,7 +210,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
...
@@ -209,7 +210,9 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// If `response.statusCode === 304`: No 'data' event and no 'end'
// If `response.statusCode === 304`: No 'data' event and no 'end'
if
(
response
.
statusCode
===
304
)
{
if
(
response
.
statusCode
===
304
)
{
return
res
.
end
();
try
{
res
.
end
()
}
catch
(
ex
)
{
console
.
error
(
"
res.end error: %s
"
,
ex
.
message
)
}
return
;
}
}
//
//
...
@@ -223,9 +226,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
...
@@ -223,9 +226,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
try
{
try
{
res
.
write
(
chunk
);
res
.
write
(
chunk
);
}
}
catch
(
er
)
{
catch
(
ex
)
{
console
.
error
(
"
res.write error: %s
"
,
ex
.
message
);
try
{
res
.
end
()
}
try
{
res
.
end
()
}
catch
(
e
r
)
{
}
catch
(
e
x
)
{
console
.
error
(
"
res.write error: %s
"
,
ex
.
message
)
}
}
}
}
}
});
});
...
@@ -240,8 +244,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
...
@@ -240,8 +244,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
response
.
on
(
'
end
'
,
function
()
{
response
.
on
(
'
end
'
,
function
()
{
if
(
!
errState
)
{
if
(
!
errState
)
{
reverseProxy
.
removeListener
(
'
error
'
,
proxyError
);
reverseProxy
.
removeListener
(
'
error
'
,
proxyError
);
res
.
end
();
try
{
res
.
end
()
}
catch
(
ex
)
{
console
.
error
(
"
res.end error: %s
"
,
ex
.
message
)
}
// Emit the `end` event now that we have completed proxying
// Emit the `end` event now that we have completed proxying
self
.
emit
(
'
end
'
,
req
,
res
);
self
.
emit
(
'
end
'
,
req
,
res
);
}
}
...
...
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