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 = {};
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 {
});
}
+var getPortForProtocol = function(protocol) {
+ switch (protocol) {
+ case 'http':
+ return 8000;
+ case 'https':
+ return 8443;
+ }
+}
+
module.exports = {
/**
* Ensure confd port is on api_server variable.
sendSuccessResponse: sendSuccessResponse,
- passThroughConstructor: passThroughConstructor
+ passThroughConstructor: passThroughConstructor,
+
+ getPortForProtocol: getPortForProtocol
};
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,
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) {
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) {