cfjedimaster / brackets-jsdownloader

JSDownloader
15 stars 12 forks source link

Proxy #24

Open GalawynRM opened 9 years ago

GalawynRM commented 9 years ago

Great work,

It's planned at least a basic support of proxy servers?

tobipch commented 9 years ago

How do you mean that?

If you mean the support of library CDNs, I would also support that...

GalawynRM commented 9 years ago

So maybe i have some kind of problem, because even if i set a proxy for brackets, JSdownloader download a 0byte file when the connection is behind proxy

cfjedimaster commented 9 years ago

No, there is no way in the plugin to make use of a proxy unless you do it it at the OS level.

On Mon, Nov 17, 2014 at 3:12 AM, GalawynRM notifications@github.com wrote:

So maybe i have some kind of problem, because even if i set a proxy for brackets, JSdownloader download a 0byte file when the connection is behind proxy

— Reply to this email directly or view it on GitHub https://github.com/cfjedimaster/brackets-jsdownloader/issues/24#issuecomment-63277073 .

Raymond Camden, Web Developer for Adobe

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden

GalawynRM commented 9 years ago

I'm checking how to enable proxy support in your extension,

could this page be useful? (brackets has in the configuration, the proxy settings, in case would be wonderful to access to those properties)

http://stackoverflow.com/a/6781592

Using a HTTP proxy (for non secure requests) is very simple. You connect to the proxy and make the request normally except that the path part includes the full url and the host header is set to the host you want to connect to. Tim was very close with his answer but he missed setting the host header properly.

var http = require("http");

var options = { host: "proxy", port: 8080, path: "http://www.google.com", headers: { Host: "www.google.com" } }; http.get(options, function(res) { console.log(res); res.pipe(process.stdout); });

cfjedimaster commented 9 years ago

Well, if there were UI for this (maybe a preferences icon in the UI) then the extension could make use of it. I'd be willing to accept a PR for this if you (or someone) wants to take a stab at it.

On Mon, Jan 19, 2015 at 7:36 AM, GalawynRM notifications@github.com wrote:

I'm checking how to enable proxy support in your extension,

could this page be useful? (brackets has in the configuration, the proxy settings, in case would be wonderful to access to those properties)

http://stackoverflow.com/a/6781592

Using a HTTP proxy (for non secure requests) is very simple. You connect to the proxy and make the request normally except that the path part includes the full url and the host header is set to the host you want to connect to. Tim was very close with his answer but he missed setting the host header properly.

var http = require("http");

var options = { host: "proxy", port: 8080, path: "http://www.google.com", headers: { Host: "www.google.com" } }; http.get(options, function(res) { console.log(res); res.pipe(process.stdout); });

— Reply to this email directly or view it on GitHub https://github.com/cfjedimaster/brackets-jsdownloader/issues/24#issuecomment-70492849 .

Raymond Camden, Web Standards Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden

GalawynRM commented 9 years ago

I'm trying to replace this from your "downloader.js"

if(item.href.indexOf("https") === 0) { https.get(item.href, resHandler); } else { http.get(item.href, resHandler); }

with similar calling as that page suggest, but for now i'm not able to make it work

cfjedimaster commented 9 years ago

It would need to use an options structure for one. Also, I'd check to see if https can use proxy. if not, then it is pretty much out of the question for the plugin. (Unless you make the UI intelligently hide the https ones and use some sort of explanation)

On Mon, Jan 19, 2015 at 8:00 AM, GalawynRM notifications@github.com wrote:

I'm trying to replace this from your "downloader.js"

if(item.href.indexOf("https") === 0) { https.get(item.href, resHandler); } else { http.get(item.href, resHandler); }

with similar calling as that page suggest, but for now i'm not able to make it work

— Reply to this email directly or view it on GitHub https://github.com/cfjedimaster/brackets-jsdownloader/issues/24#issuecomment-70495821 .

Raymond Camden, Web Standards Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden

GalawynRM commented 9 years ago

is this helping for https ones? they suggest to use "Request" (i'm new to node.js and brackets extensions)

http://stackoverflow.com/a/21281075

Request, https://github.com/request/request

GalawynRM commented 9 years ago

i got some results with this

https://www.npmjs.com/package/global-tunnel

adding to the downloader.js

var globalTunnel = require('global-tunnel');

(but i needed to npm install it, i don't know if it's possible from a bracket extension installation.

there is even an option for global tunnel, to use the environment variables http_proxy.. etc.

cfjedimaster commented 9 years ago

Well, I wish you luck. :) It isn't that I don't want to help per se, but I don't have the time right now to work on this. I am in favor of the PR though as I said.

On Mon, Jan 19, 2015 at 8:27 AM, GalawynRM notifications@github.com wrote:

i got some results with this

https://www.npmjs.com/package/global-tunnel

adding to the downloader.js

var globalTunnel = require('global-tunnel');

(but i needed to npm install it, i don't know if it's possible from a bracket extension installation.

there is even an option for global tunnel, to use the environment variables http_proxy.. etc.

— Reply to this email directly or view it on GitHub https://github.com/cfjedimaster/brackets-jsdownloader/issues/24#issuecomment-70500063 .

Raymond Camden, Web Standards Evangelist

Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden

GalawynRM commented 9 years ago

Yes of course, I'm trying to find a possible generic solution.

for now it's working on my local version, but with a require, that i don't know how to "embed" into the extension