Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pub to use an HTTP proxy #5454

Closed
sethladd opened this issue Sep 25, 2012 · 19 comments
Closed

Allow pub to use an HTTP proxy #5454

sethladd opened this issue Sep 25, 2012 · 19 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug

Comments

@sethladd
Copy link
Contributor

Command line apps that access HTTP resources, like pub, should allow for proxy configurations. Proxies are used in corporate environments.

@sgjesse
Copy link
Contributor

sgjesse commented Sep 26, 2012

Pub is written in Dart and uses HttpClient from dart:io to fetch its resources. Therefore this requires HttpClient to support a proxy configuration.


Marked this as being blocked by #5468.

@munificent
Copy link
Member

Added this to the Later milestone.

@DartBot
Copy link

DartBot commented Nov 6, 2012

This comment was originally written by laurent.ploi...@gmail.com


Not having it prevents corporate users from testing dart with the todomvc example. See error logs:

Running pub install ...
Pub install fail, Resolving dependencies...
SocketIOException: Connection failed (OS Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
, errno = 10060)

/todomvc/build.dart
Failed with error code 255
  Unable to open file: C:/Programs/dart/samples/todomvc/packages/web_components/component_build.dart'file:///C:/Programs/dart/samples/todomvc/build.dart': Error: line 7 pos 1: library handler failed
  import 'package:web_components/component_build.dart';
  ^

@sgjesse
Copy link
Contributor

sgjesse commented Nov 6, 2012

The HttpClient have support for HTTP proxies as long as they do not require authentication and should not tunnel HTTPS connections, See http://code.google.com/p/dart/issues/detail?id=5468 and HttpClinet.findProxy (http://api.dartlang.org/docs/bleeding_edge/dart_io/HttpClient.html#findProxy=) for details.

@DartBot
Copy link

DartBot commented Nov 6, 2012

This comment was originally written by laurent....@gmail.com


Thanks @­sgjesse
In fact, most corporate environments do require authentication.

@DartBot
Copy link

DartBot commented Jan 4, 2013

This comment was originally written by petr.jiricka...@gmail.com


Until HttpClient supports authentication, it would be useful to at least expose support for non-authenticated proxies in pub, and authentication can be added later.

@DartBot
Copy link

DartBot commented Jan 16, 2013

This comment was originally written by geert.wl.clae...@gmail.com


Since this issue was already raised in September I am a bit baffled as to why it hasn't been given a higher priority then "Milestone: later"? I understand that there is a lot of other studd to deal with but this surely doesn't look good as Dart aims to be the solution for large/complex web apps ... and who would be interrested in something like that I wonder? :)

@sethladd
Copy link
Contributor Author

Hi Geert,

I understand your concerns, and you're right... there's a lot of stuff to deal with when implementing a whole new platform.

Our prioritization is influenced in part by developer demand. A good way to affect this is to star issues, which is a way to vote for them. Another way to affect change is to advocate for issues on the mailing list, to drum up support for the issues.

What also helps is detailing the use cases that are driving the issue. It really helps for us to understand what this is blocking (e.g. is your company or business trying to use Dart but is blocked by issue XX ?)

Thanks very much for the feedback. We do listen, it really does help.

@DartBot
Copy link

DartBot commented Jan 16, 2013

This comment was originally written by geert.wl.clae...@gmail.com


No worries Seth, as I said, I perfectly understand that this is not the only issue the Dart team has to deal with.

It just that its kinda of a dealbreaker at the moment for those who are behind a corporate proxy that requires authentication and want to put together a nice Dart prototype app (btw, I love the Dart Widget stuff Kevin Moore is putting together).

From how people are voting on StackOverflow I have a feeling not many are behind a proxy. Anyhow, I (as you know, since you replied to me there as well) came here via: http://stackoverflow.com/questions/14316430/dart-pub-update-failed

@sgjesse
Copy link
Contributor

sgjesse commented Jan 17, 2013

Geert,

I was wondering whether the proxy support in dart:io will work for you.
Could you please try to run the script below with line 7 changed to your
proxy configuration.?

import 'dart:io';
import 'dart:uri';

main() {
  HttpClient client = new HttpClient();

  client.findProxy = (Uri uri) => "PROXY localhost:8080;";

  HttpClientConnection conn =
      client.getUrl(new Uri.fromString("http://pub.dartlang.org"));
  conn.onResponse = (HttpClientResponse response) {
    response.inputStream.onData = () =>
        print(new String.fromCharCodes(response.inputStream.read()));
    response.inputStream.onClosed = () {
      client.shutdown();
    };
  };
}

Regards,
Søren

@DartBot
Copy link

DartBot commented Jan 17, 2013

This comment was originally written by geert.wl.cla...@gmail.com


Hi Søren, Since our connection goes via an automatic configuration script (.pac) I tried replacing the proxy in line 7 with the Address to the .pac but got a "java.net.ConnectException: Connecrtion Refused: connect"

@sgjesse
Copy link
Contributor

sgjesse commented Jan 17, 2013

Hi Geert

We cannot support automatic configuration script (.pac) directly in Dart. A .pac is a JavaScript script intended for running in a browser. When a .pac script is used the .pac function FindProxyForURL is called and the returned string is then interpreted by the browser, e.g.:

function FindProxyForURL(url, host)
{
  return "PROXY proxy.example.com:8080; DIRECT";
}

The string returned by HttpClient.findProxy callback uses the same format as .pac scripts.

There are several standalone .pac evaluators out there, one is https://code.google.com/p/pacparser/. If you use that with the following Python script you should get the string to be used in line 7.

import pacparser
pacparser.init()
pacparser.parse_pac_file('wpad.dat')
print pacparser.find_proxy('http://pub.dartlang.org', 'pub.dartlang.org')
pacparser.cleanup()

Regards,
Søren

@DartBot
Copy link

DartBot commented Jan 23, 2013

This comment was originally written by adamlesia...@gmail.com


Hi, the workaround i'm using is:

  1. configure http_proxy
  2. make sure that curl works fine (curl http://pub.dartlang.org)
  3. change dart-sdk\util\pub\http.dart
    replace
    /// The HTTP client to use for all HTTP requests.
    final httpClient = new PubHttpClient();

with
final httpClient = new PubHttpClient(new CurlClient());

Do you have a simpler one?

@DartBot
Copy link

DartBot commented Jan 23, 2013

This comment was originally written by geert.wl....@gmail.com


I would prefer for the editor to simply use the System Proxy Settings just like Chrome/Firefox etc does. This issue seems to be linked to issue #5455 which is marked as accepted for the upcoming M3 so shouldn't the Milestone for this issue also be M3?

@DartBot
Copy link

DartBot commented Jan 23, 2013

This comment was originally written by adamlesi...@gmail.com


I cannot agree more, this one is a showstopper in corporate environment.

@DartBot
Copy link

DartBot commented Jan 23, 2013

This comment was originally written by empyreanst...@gmail.com


The workaround in #­13 is great, thanks! A caveat on OS X Lion however: After editing html.dart, I tried to test it using

$ launchctl setenv http_proxy http://my.corporate.proxy

and the Dart Editor still failed to connect. This was without restarting Dart Editor or trying any other troubleshooting though, so this failure isn't definitive. Regardless, to me lack of proxy support in the Dart Editor is not important since the command line tool works: after exporting http_proxy in my shell, running

../project_dir $ path/to/dart-sdk/bin/pub update

worked perfectly. If I may share an opinion, this workaround seems acceptable for corporate environments, especially when compared to my previous approach (downloading each dependency by hand to ~/.pub_cache)

@DartBot
Copy link

DartBot commented Feb 19, 2013

This comment was originally written by dtcac...@gmail.com


Since CurlClient is not available in trunk anymore, I recently tried to apply #­10 globally to http://code.google.com/p/dart/source/browse/trunk/dart/pkg/http/lib/src/io_client.dart#­21 by adding _inner.findProxy = (Uri uri) => "PROXY ...;. This resulted in

  Got socket error trying to find package "web_ui" at https://pub.dartlang.org.
  OS Error: errno = -12263

which according to search means "SSL received a record that exceeded the maximum permissible length." Would it be a problem in Dart SSL implementation or am I doing this wrong?

@sgjesse
Copy link
Contributor

sgjesse commented Feb 20, 2013

This is a bug in the HTTP proxy implementation. The problem is that the Dart code tries to make a secure connection to the proxy server when the destination URL has scheme HTTPS.

Proposed fix for this in https://codereview.chromium.org/12314007/

@sgjesse
Copy link
Contributor

sgjesse commented Feb 20, 2013

The issue reported in #­17 is fixed in https://code.google.com/p/dart/source/detail?r=18759.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants