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
cd78af5f
Commit
cd78af5f
authored
Sep 15, 2010
by
Fedor Indutny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'end' event becomes 'close', added more try-catch handling
parent
7249ef3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
lib/node-http-proxy.js
lib/node-http-proxy.js
+36
-13
No files found.
lib/node-http-proxy.js
View file @
cd78af5f
...
...
@@ -315,22 +315,36 @@ HttpProxy.prototype = {
sdata
=
sdata
.
replace
(
remote_host
,
host
)
.
replace
(
remote_host
,
host
);
try
{
// Write printable
socket
.
write
(
sdata
);
// Write printable
socket
.
write
(
sdata
);
// Write non-printable
socket
.
write
(
data
);
// Write non-printable
socket
.
write
(
data
);
}
catch
(
e
)
{
request
.
end
();
socket
.
end
();
}
// Catch socket errors
socket
.
on
(
'
error
'
,
function
()
{
request
.
end
();
});
// Remove data listener
request
.
socket
.
removeListener
(
'
data
'
,
t
);
});
// Write upgrade-head
request
.
write
(
head
);
try
{
request
.
write
(
head
);
}
catch
(
e
)
{
request
.
end
();
socket
.
end
();
}
self
.
unwatch
(
socket
);
});
// Request
function
onUpgrade
(
reverse_proxy
)
{
...
...
@@ -340,14 +354,23 @@ HttpProxy.prototype = {
reverse_proxy
.
on
(
'
data
'
,
listeners
.
_r_data
=
function
(
data
)
{
// Pass data to client
if
(
socket
.
writable
)
{
socket
.
write
(
data
);
try
{
socket
.
write
(
data
);
}
catch
(
e
)
{
socket
.
end
();
reverse_proxy
.
end
();
}
}
});
socket
.
on
(
'
data
'
,
listeners
.
_data
=
function
(
data
){
// Pass data from client to server
// Socket thougth that it isn't writable
reverse_proxy
.
write
(
data
);
try
{
reverse_proxy
.
write
(
data
);
}
catch
(
e
)
{
reverse_proxy
.
end
();
socket
.
end
();
}
});
// Detach event listeners from reverse_proxy
...
...
@@ -359,12 +382,12 @@ HttpProxy.prototype = {
}
// Hook disconnections
reverse_proxy
.
on
(
'
close
'
,
listeners
.
_r_close
=
function
()
{
reverse_proxy
.
on
(
'
end
'
,
listeners
.
_r_close
=
function
()
{
socket
.
end
();
detach
();
});
socket
.
on
(
'
close
'
,
listeners
.
_close
=
function
()
{
socket
.
on
(
'
end
'
,
listeners
.
_close
=
function
()
{
reverse_proxy
.
end
();
detach
();
});
...
...
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