Commit 44a85664 authored by indexzero's avatar indexzero

[test] Continued work around Origin mismatch tests

parent 9ab54ab4
......@@ -588,12 +588,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
_socket(socket);
// Remote host address
var agent = _getAgent(options.host, options.port),
remoteHost = options.host + (options.port - 80 === 0 ? '' : ':' + options.port);
var protocolName = options.https || this.https ? 'https' : 'http',
agent = _getAgent(options.host, options.port),
remoteHost = options.host + (options.port - 80 === 0 ? '' : ':' + options.port);
// Change headers
req.headers.host = remoteHost;
req.headers.origin = 'http://' + options.host;
req.headers.origin = protocolName + '://' + options.host;
outgoing = {
host: options.host,
......
......@@ -29,6 +29,7 @@ var vows = require('vows'),
colors = require('colors'),
request = require('request'),
assert = require('assert'),
argv = require('optimist').argv,
websocket = require('./../vendor/websocket'),
helpers = require('./helpers');
......@@ -42,8 +43,11 @@ catch (ex) {
process.exit(1);
}
var runner = new helpers.TestRunner();
var protocol = argv.https ? 'https' : 'http',
wsprotocol = argv.https ? 'wss' : 'ws',
runner = new helpers.TestRunner(protocol);
require('eyes').inspect(protocol);
vows.describe('node-http-proxy/websocket').addBatch({
"When using server created by httpProxy.createServer()": {
"with no latency" : {
......@@ -65,8 +69,8 @@ vows.describe('node-http-proxy/websocket').addBatch({
//
// Setup the web socket against our proxy
//
var ws = new websocket.WebSocket('ws://localhost:8131/socket.io/websocket/', 'borf', {
origin: 'http://localhost'
var ws = new websocket.WebSocket(wsprotocol + '://localhost:8131/socket.io/websocket/', 'borf', {
origin: 'https://localhost'
});
ws.on('wsupgrade', function (req, res) {
......@@ -101,8 +105,8 @@ vows.describe('node-http-proxy/websocket').addBatch({
//
// Setup the web socket against our proxy
//
var ws = new websocket.WebSocket('ws://localhost:8133/socket.io/websocket/', 'borf', {
origin: 'http://localhost'
var ws = new websocket.WebSocket(wsprotocol + '://localhost:8133/socket.io/websocket/', 'borf', {
origin: 'https://localhost'
});
ws.on('wsupgrade', function (req, res) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment