twolfson / grunt-curl

Download files from the internet via grunt.
The Unlicense
73 stars 28 forks source link

Proxy #20

Closed MartinMa closed 10 years ago

MartinMa commented 10 years ago

Is it possible to have grunt-curl use a proxy server?

If not, where can I start for a quick fix / hack to make it work?

MartinMa commented 10 years ago

Ok I found a quick fix. Open grunt-curl\tasks\curl.js and replace line 140 at the bottom with this:

request.get({'url': url, 'encoding': 'binary', 'proxy': 'http://127.0.0.1:3128/'}, function (err, res, body) {

whereas http://127.0.0.1:3128/ is the proxy address.

One can think about adding an option to grunt-curl which passes the proxy url through to the request function. Another possibility would be to set request.defaults once. I'm very new to grunt, I don't know what's best to handle this stuff.

twolfson commented 10 years ago

grunt-curl passes through src directly to request. You should be fine with

curl: {
  'my-task': {
    src: {
      url: 'http://google.com',
      proxy: 'http://127.0.0.1:3128/'
    },
    dest: 'google.html'
  }
}
MartinMa commented 10 years ago

Thanks for the hint!

cg-zeno-yu commented 10 years ago

Thanks for the great tool, is it possible to update the documenation on https://www.npmjs.org/package/grunt-curl for this great feature please? It is a rescue for those behind the corporate firewall

twolfson commented 10 years ago

Technically this is documented via

Both tasks support accepting request parameters as a src file. Here is an example creating a POST request.

but we can add an example to highlight this specific case. I will add it by the end of this weekend.

twolfson commented 10 years ago

@cg-zeno-yu I have added an example of using a proxy to the README. Released in 2.0.3

https://github.com/twolfson/grunt-curl#using-a-proxy

cg-zeno-yu commented 10 years ago

Thanks! Appreciate your work, it is amazing

MartinMa commented 10 years ago

:+1: