From dd6b2a449ec1e076a4f5d54ee246f9ffa43472ed Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Fri, 14 Nov 2014 17:23:08 +0300 Subject: [PATCH] Correctly use https scheme for download RPC when FS_SSL config is set. Fixes #43. --- lib/tasks.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/tasks.coffee b/lib/tasks.coffee index 1379bf0..0bb1dad 100644 --- a/lib/tasks.coffee +++ b/lib/tasks.coffee @@ -43,6 +43,7 @@ common = require './common' db = require './db' mongodb = require 'mongodb' customCommands = require './custom-commands' +url = require 'url' exports.STATUS_OK = STATUS_OK = 1 exports.STATUS_FAULT = STATUS_FAULT = 2 @@ -330,11 +331,18 @@ this.download = (task, methodResponse, callback) -> callback(err) return + l = { + protocol : if config.get('FS_SSL') then 'https' else 'http', + hostname : config.get('FS_IP'), + port : config.get('FS_PORT'), + pathname : encodeURIComponent(file.filename) + } + methodRequest = { type : 'Download', fileType : file.metadata.fileType, fileSize : file.length, - url : "http://#{config.get('FS_IP')}:#{config.get('FS_PORT')}/#{encodeURIComponent(file.filename)}", + url : url.format(l), successUrl : task.successUrl, failureUrl : task.failureUrl }