Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6911 from adobe/dangoor/extman-proxy
Browse files Browse the repository at this point in the history
Add proxy support for extension installation.
  • Loading branch information
JeffryBooher committed Feb 20, 2014
2 parents f16b648 + 97bbeca commit 16991f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ define(function (require, exports, module) {
StringUtils = require("utils/StringUtils"),
Strings = require("strings"),
ExtensionLoader = require("utils/ExtensionLoader"),
NodeConnection = require("utils/NodeConnection");
NodeConnection = require("utils/NodeConnection"),
PreferencesManager = require("preferences/PreferencesManager");

PreferencesManager.definePreference("proxy", "string");

var Errors = {
ERROR_LOADING: "ERROR_LOADING",
Expand Down Expand Up @@ -246,7 +249,7 @@ define(function (require, exports, module) {
}

// Download the bits (using Node since brackets-shell doesn't support binary file IO)
var r = extensionManager.downloadFile(downloadId, urlInfo.url);
var r = extensionManager.downloadFile(downloadId, urlInfo.url, PreferencesManager.get("proxy"));
r.done(function (result) {
d.resolve({ localPath: result, filenameHint: urlInfo.filenameHint });
}).fail(function (err) {
Expand Down
15 changes: 13 additions & 2 deletions src/extensibility/node/ExtensionManagerDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,22 @@ function _endDownload(downloadId, error) {
/**
* Implements "downloadFile" command, asynchronously.
*/
function _cmdDownloadFile(downloadId, url, callback) {
function _cmdDownloadFile(downloadId, url, proxy, callback) {
// Backwards compatibility check, added in 0.37
if (typeof proxy === "function") {
callback = proxy;
proxy = undefined;
}

if (pendingDownloads[downloadId]) {
callback(Errors.DOWNLOAD_ID_IN_USE, null);
return;
}

var req = request.get({
url: url,
encoding: null
encoding: null,
proxy: proxy
},
// Note: we could use the traditional "response"/"data"/"end" events too if we wanted to stream data
// incrementally, limit download size, etc. - but the simple callback is good enough for our needs.
Expand Down Expand Up @@ -593,6 +600,10 @@ function init(domainManager) {
name: "url",
type: "string",
description: "URL to download from"
}, {
name: "proxy",
type: "string",
description: "optional proxy URL"
}],
{
type: "string",
Expand Down

0 comments on commit 16991f2

Please sign in to comment.