From: KIRAN KASHALKAR Date: Wed, 18 Jan 2017 16:28:22 +0000 (-0500) Subject: Resolving Bug 155 X-Git-Tag: v1.1.0~18 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F979%2F1;p=osm%2FUI.git Resolving Bug 155 --- diff --git a/skyquake/framework/core/api_utils/sockets.js b/skyquake/framework/core/api_utils/sockets.js index 607659476..5e0b25bfb 100644 --- a/skyquake/framework/core/api_utils/sockets.js +++ b/skyquake/framework/core/api_utils/sockets.js @@ -32,17 +32,9 @@ var Promise = require('promise'); var url = require('url'); var sockjs = require('sockjs'); var websocket_multiplex = require('websocket-multiplex'); +var utils = require('./utils.js'); -function getPortForProtocol (protocol) { - switch (protocol) { - case 'http': - return 8000; - case 'https': - return 8443; - } -} - var Subscriptions = function() { this.ID = 0; this.socketServers = {}; @@ -85,7 +77,7 @@ Subscriptions.prototype.subscribe = function(req, callback) { var origin = ''; if (req.query['api_server']) { var api_server_protocol = req.query['api_server'].match(protocolTest)[1]; - var api_server_origin = req.query['api_server'] + ':' + getPortForProtocol(api_server_protocol); + var api_server_origin = req.query['api_server'] + ':' + utils.getPortForProtocol(api_server_protocol); origin = api_server_origin; protocol = api_server_protocol; } else { diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js index 0d1990c64..5b17279d5 100644 --- a/skyquake/framework/core/api_utils/utils.js +++ b/skyquake/framework/core/api_utils/utils.js @@ -217,6 +217,15 @@ var passThroughConstructor = function(app) { }); } +var getPortForProtocol = function(protocol) { + switch (protocol) { + case 'http': + return 8000; + case 'https': + return 8443; + } +} + module.exports = { /** * Ensure confd port is on api_server variable. @@ -233,5 +242,7 @@ module.exports = { sendSuccessResponse: sendSuccessResponse, - passThroughConstructor: passThroughConstructor + passThroughConstructor: passThroughConstructor, + + getPortForProtocol: getPortForProtocol }; diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js index 8df1a9123..dde9bcd54 100644 --- a/skyquake/plugins/composer/api/composer.js +++ b/skyquake/plugins/composer/api/composer.js @@ -312,7 +312,7 @@ Composer.update = function(req) { var download_host = req.query['dev_download_server']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } var input = { 'external-url': download_host + '/composer/update/' + req.file.filename, @@ -368,7 +368,7 @@ Composer.upload = function(req) { var download_host = req.query['dev_download_server']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } return new Promise(function(resolve, reject) { @@ -425,7 +425,7 @@ Composer.addFile = function(req) { var package_type = req.query['package_type'].toUpperCase(); var package_path = req.query['package_path']; if (!download_host) { - download_host = req.protocol + '://' + req.headers.host; + download_host = api_server + ':' + utils.getPortForProtocol(req.protocol); } return new Promise(function(resolve, reject) {