mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[refactor minor] Update vendor/websocket.js to be compatible with node@0.6.x
This commit is contained in:
parent
5b52c89694
commit
ea7fea6272
32
vendor/websocket.js
vendored
32
vendor/websocket.js
vendored
@ -496,7 +496,7 @@ var WebSocket = function(url, proto, opts) {
|
|||||||
if (u.protocol === 'ws:' || u.protocol === 'wss:') {
|
if (u.protocol === 'ws:' || u.protocol === 'wss:') {
|
||||||
protocol = u.protocol === 'ws:' ? http : https;
|
protocol = u.protocol === 'ws:' ? http : https;
|
||||||
port = u.protocol === 'ws:' ? 80 : 443;
|
port = u.protocol === 'ws:' ? 80 : 443;
|
||||||
agent = u.protocol === 'ws:' ? protocol.getAgent(u.hostname, u.port || port) : protocol.getAgent({
|
agent = u.protocol === new protocol.Agent({
|
||||||
host: u.hostname,
|
host: u.hostname,
|
||||||
port: u.port || port
|
port: u.port || port
|
||||||
});
|
});
|
||||||
@ -514,8 +514,20 @@ var WebSocket = function(url, proto, opts) {
|
|||||||
throw new Error('Invalid URL scheme \'' + urlScheme + '\' specified.');
|
throw new Error('Invalid URL scheme \'' + urlScheme + '\' specified.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!agent._events || agent._events['upgrade'].length === 0) {
|
var httpReq = protocol.request({
|
||||||
agent.on('upgrade', (function() {
|
host: u.hostname,
|
||||||
|
method: 'GET',
|
||||||
|
agent: agent,
|
||||||
|
port: u.port,
|
||||||
|
path: httpPath,
|
||||||
|
headers: httpHeaders
|
||||||
|
});
|
||||||
|
|
||||||
|
httpReq.on('error', function (e) {
|
||||||
|
errorListener(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
httpReq.on('upgrade', (function() {
|
||||||
var data = undefined;
|
var data = undefined;
|
||||||
|
|
||||||
return function(res, s, head) {
|
return function(res, s, head) {
|
||||||
@ -607,20 +619,6 @@ var WebSocket = function(url, proto, opts) {
|
|||||||
stream.emit('data', head);
|
stream.emit('data', head);
|
||||||
};
|
};
|
||||||
})());
|
})());
|
||||||
}
|
|
||||||
|
|
||||||
agent.on('error', function (e) {
|
|
||||||
errorListener(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
var httpReq = protocol.request({
|
|
||||||
host: u.hostname,
|
|
||||||
method: 'GET',
|
|
||||||
agent: agent,
|
|
||||||
port: u.port,
|
|
||||||
path: httpPath,
|
|
||||||
headers: httpHeaders
|
|
||||||
});
|
|
||||||
|
|
||||||
httpReq.write(challenge, 'binary');
|
httpReq.write(challenge, 'binary');
|
||||||
httpReq.end();
|
httpReq.end();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user