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

Add proxy support for extension installation. #6911

Merged
merged 1 commit into from
Feb 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not if (typeof proxy !== "string") instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nevermind, maybe you need else if (typeof proxy !== "string") just to make sure we're not passing garbage in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disregard that as well. I see we don't really do much parameter validation as it is.

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