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
ec03d72c
Commit
ec03d72c
authored
Sep 08, 2011
by
indexzero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[minor] Move private methods to the bottom of file(s)
parent
0e369129
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
73 deletions
+73
-73
lib/node-http-proxy.js
lib/node-http-proxy.js
+1
-1
lib/node-http-proxy/http-proxy.js
lib/node-http-proxy/http-proxy.js
+72
-72
No files found.
lib/node-http-proxy.js
View file @
ec03d72c
...
...
@@ -153,7 +153,7 @@ exports.createServer = function () {
// __Attribution:__ This approach is based heavily on
// [Connect](https://github.com/senchalabs/connect/blob/master/lib/utils.js#L157).
// However, this is not a big leap from the implementation in node-http-proxy < 0.4.0.
// This simply chooses to manage the scope of
the events on a new Object literal as opposed to
// This simply chooses to manage the scope of the events on a new Object literal as opposed to
// [on the HttpProxy instance](https://github.com/nodejitsu/node-http-proxy/blob/v0.3.1/lib/node-http-proxy.js#L154).
//
exports
.
buffer
=
function
(
obj
)
{
...
...
lib/node-http-proxy/http-proxy.js
View file @
ec03d72c
...
...
@@ -323,78 +323,6 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
}
};
//
// ### @private function _forwardRequest (req)
// #### @req {ServerRequest} Incoming HTTP Request to proxy.
// Forwards the specified `req` to the location specified
// by `this.forward` ignoring errors and the subsequent response.
//
HttpProxy
.
prototype
.
_forwardRequest
=
function
(
req
)
{
var
self
=
this
,
outgoing
=
new
(
this
.
forward
.
base
),
forwardProxy
;
//
// Setup outgoing proxy with relevant properties.
//
outgoing
.
host
=
this
.
forward
.
host
;
outgoing
.
port
=
this
.
forward
.
port
,
outgoing
.
agent
=
this
.
forward
.
agent
;
outgoing
.
method
=
req
.
method
;
outgoing
.
path
=
req
.
url
;
outgoing
.
headers
=
req
.
headers
;
//
// Open new HTTP request to internal resource with will
// act as a reverse proxy pass.
//
forwardProxy
=
this
.
forward
.
protocol
.
request
(
outgoing
,
function
(
response
)
{
//
// Ignore the response from the forward proxy since this is a 'fire-and-forget' proxy.
// Remark (indexzero): We will eventually emit a 'forward' event here for performance tuning.
//
});
//
// Add a listener for the connection timeout event.
//
// Remark: Ignoring this error in the event
// forward target doesn't exist.
//
forwardProxy
.
once
(
'
error
'
,
function
(
err
)
{
});
//
// Chunk the client request body as chunks from
// the proxied request come in
//
req
.
on
(
'
data
'
,
function
(
chunk
)
{
var
flushed
=
forwardProxy
.
write
(
chunk
);
if
(
!
flushed
)
{
req
.
pause
();
forwardProxy
.
once
(
'
drain
'
,
function
()
{
try
{
req
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
)
}
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout
(
function
()
{
forwardProxy
.
emit
(
'
drain
'
);
},
100
);
}
});
//
// At the end of the client request, we are going to
// stop the proxied request
//
req
.
on
(
'
end
'
,
function
()
{
forwardProxy
.
end
();
});
};
//
// ### function proxyWebSocketRequest (req, socket, head, buffer)
// #### @req {ServerRequest} Websocket request to proxy.
...
...
@@ -733,3 +661,75 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
:
buffer
.
destroy
();
}
};
//
// ### @private function _forwardRequest (req)
// #### @req {ServerRequest} Incoming HTTP Request to proxy.
// Forwards the specified `req` to the location specified
// by `this.forward` ignoring errors and the subsequent response.
//
HttpProxy
.
prototype
.
_forwardRequest
=
function
(
req
)
{
var
self
=
this
,
outgoing
=
new
(
this
.
forward
.
base
),
forwardProxy
;
//
// Setup outgoing proxy with relevant properties.
//
outgoing
.
host
=
this
.
forward
.
host
;
outgoing
.
port
=
this
.
forward
.
port
,
outgoing
.
agent
=
this
.
forward
.
agent
;
outgoing
.
method
=
req
.
method
;
outgoing
.
path
=
req
.
url
;
outgoing
.
headers
=
req
.
headers
;
//
// Open new HTTP request to internal resource with will
// act as a reverse proxy pass.
//
forwardProxy
=
this
.
forward
.
protocol
.
request
(
outgoing
,
function
(
response
)
{
//
// Ignore the response from the forward proxy since this is a 'fire-and-forget' proxy.
// Remark (indexzero): We will eventually emit a 'forward' event here for performance tuning.
//
});
//
// Add a listener for the connection timeout event.
//
// Remark: Ignoring this error in the event
// forward target doesn't exist.
//
forwardProxy
.
once
(
'
error
'
,
function
(
err
)
{
});
//
// Chunk the client request body as chunks from
// the proxied request come in
//
req
.
on
(
'
data
'
,
function
(
chunk
)
{
var
flushed
=
forwardProxy
.
write
(
chunk
);
if
(
!
flushed
)
{
req
.
pause
();
forwardProxy
.
once
(
'
drain
'
,
function
()
{
try
{
req
.
resume
()
}
catch
(
er
)
{
console
.
error
(
"
req.resume error: %s
"
,
er
.
message
)
}
});
//
// Force the `drain` event in 100ms if it hasn't
// happened on its own.
//
setTimeout
(
function
()
{
forwardProxy
.
emit
(
'
drain
'
);
},
100
);
}
});
//
// At the end of the client request, we are going to
// stop the proxied request
//
req
.
on
(
'
end
'
,
function
()
{
forwardProxy
.
end
();
});
};
\ No newline at end of file
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