Skip to content

Commit

Permalink
[refactor] Updates to support http2 from @mikeal
Browse files Browse the repository at this point in the history
Conflicts:

	lib/node-http-proxy/http-proxy.js
  • Loading branch information
indexzero authored and mmalecki committed Dec 14, 2011
1 parent 86b4122 commit 5b52c89
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -25,6 +25,7 @@
*/

var events = require('events'),
http = require('http'),

This comment has been minimized.

Copy link
@Rob--W

Rob--W Aug 28, 2013

This import seems to be unused. Why did you import "http"?

util = require('util'),
httpProxy = require('../node-http-proxy');

Expand Down Expand Up @@ -594,6 +595,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
outgoing.method = 'GET';
outgoing.path = req.url;
outgoing.headers = req.headers;
outgoing.agent = agent;

var reverseProxy = this.target.protocol.request(outgoing);

Expand All @@ -617,7 +619,6 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// available to the `upgrade` event. This bookkeeping is not tracked anywhere
// in nodejs core and is **very** specific to proxying WebSockets.
//
reverseProxy.agent = agent;
reverseProxy.incoming = {
request: req,
socket: socket,
Expand All @@ -632,17 +633,15 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// In addition, it's important to note the closure scope here. Since
// there is no mapping of the socket to the request bound to it.
//
if (!agent._events || agent._events['upgrade'].length === 0) {
agent.on('upgrade', function (_, remoteSocket, head) {
//
// Prepare the socket for the reverseProxy request and begin to
// stream data between the two sockets. Here it is important to
// note that `remoteSocket._httpMessage === reverseProxy`.
//
_socket(remoteSocket, true);
onUpgrade(remoteSocket._httpMessage, remoteSocket);
});
}
reverseProxy.on('upgrade', function (_, remoteSocket, head) {
//
// Prepare the socket for the reverseProxy request and begin to
// stream data between the two sockets. Here it is important to
// note that `remoteSocket._httpMessage === reverseProxy`.
//
_socket(remoteSocket, true);
onUpgrade(remoteSocket._httpMessage, remoteSocket);
});

//
// If the reverseProxy connection has an underlying socket,
Expand Down

0 comments on commit 5b52c89

Please sign in to comment.