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
7bda25b1
Commit
7bda25b1
authored
Aug 28, 2011
by
isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add guards to every throw-able res.end call
parent
62201a09
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
lib/node-http-proxy.js
lib/node-http-proxy.js
+27
-6
No files found.
lib/node-http-proxy.js
View file @
7bda25b1
...
@@ -404,8 +404,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
...
@@ -404,8 +404,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
// then respond with `404` since we do not have a valid proxy target.
// then respond with `404` since we do not have a valid proxy target.
//
//
if
(
!
location
)
{
if
(
!
location
)
{
try
{
res
.
writeHead
(
404
);
res
.
writeHead
(
404
);
return
res
.
end
();
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.writeHead/res.end error: %s
"
,
er
.
message
);
}
return
;
}
}
//
//
...
@@ -480,7 +485,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
...
@@ -480,7 +485,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
}
}
}
}
try
{
res
.
end
();
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
);
}
}
}
outgoing
=
{
outgoing
=
{
...
@@ -508,7 +517,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
...
@@ -508,7 +517,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
// `response.statusCode === 304`: No 'data' event and no 'end'
// `response.statusCode === 304`: No 'data' event and no 'end'
if
(
response
.
statusCode
===
304
)
{
if
(
response
.
statusCode
===
304
)
{
return
res
.
end
();
try
{
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
)
}
return
;
}
}
// For each data `chunk` received from the `reverseProxy`
// For each data `chunk` received from the `reverseProxy`
...
@@ -520,9 +534,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
...
@@ -520,9 +534,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
try
{
try
{
res
.
write
(
chunk
);
res
.
write
(
chunk
);
}
catch
(
er
)
{
}
catch
(
er
)
{
console
.
error
(
"
res.write error: %s
"
,
er
.
message
);
try
{
try
{
res
.
end
();
res
.
end
();
}
catch
(
er
)
{}
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
message
);
}
}
}
}
}
});
});
...
@@ -535,7 +552,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
...
@@ -535,7 +552,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
response
.
on
(
'
end
'
,
function
()
{
response
.
on
(
'
end
'
,
function
()
{
if
(
!
errState
)
{
if
(
!
errState
)
{
reverseProxy
.
removeListener
(
'
error
'
,
proxyError
);
reverseProxy
.
removeListener
(
'
error
'
,
proxyError
);
try
{
res
.
end
();
res
.
end
();
}
catch
(
er
)
{
console
.
error
(
"
res.end error: %s
"
,
er
.
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