-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support proxy configuration in HttpClient #5468
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
Comments
Marked this as blocking #5454. |
I propose to make the proxy configuration be very much like the PAC scripts used for web browsers. Of cause using Dart code instead of JavaScript code. This could be done by having the ability to set proxy resolver function on an HttpClient, e.g. abstract class HttpClient { ... void set findProxy(void finder(Uri url)); The function findProxy will return a string in the same format as is used by PAC scripts. We then need to make the functions available to PAC scripts (see http://findproxyforurl.com/pac-functions/) available in Dart. The default, if findProxy is not set, will be not to use a proxy, which is the same as the following function: HttpClient client = ... Always using the same proxy is also simple: HttpClient client = ... |
Support for the findProxy approach described above is implemented in https://code.google.com/p/dart/source/detail?r=13348 and What is now missing is support for tunneling using the CONNECT method when contacting the proxy. This is mostly required for HTTPS, but could also be supported for HTTP. There is no specified way of configuring when to use a tunnel, but the simple heuristic is to use it for HTTPS connections only. If is should be supported for HTTP as well some kind of additional configuration will be required. An additional issue is using secure transport between the HTTP client and the proxy server. For that the Chromium is using a extension of the PAC script, where HTTPS is used instead of PROXY, see http://www.chromium.org/developers/design-documents/secure-web-proxy and http://www.chromium.org/spdy/spdy-proxy. Marking this as blocked on HTTPS support for now. Marked this as being blocked by #3593. |
Added builtin support for using environment variables to configure the HTTP proxy in https://code.google.com/p/dart/source/detail?r=20202. |
This comment was originally written by [email protected] When is M4 planned for because this is really a pita? |
Made the environment configuration the default for HttpClient in https://code.google.com/p/dart/source/detail?r=21332. |
Proposed change to proxies requiring authentication in https://codereview.chromium.org/13915007/. |
Proxy authentication added in https://code.google.com/p/dart/source/detail?r=21417 Only CONNECT support is now missing. Removed this from the M4 milestone. |
Support for the CONNECT method was added in https://code.google.com/p/dart/source/detail?r=22119. Added Fixed label. |
This comment was originally written by [email protected] I still get error even when https_proxy is configured and curl -v https://pub.dartlang.org/packages/web_ui.json works and I am using untested dart-sdk which includes r22119 change. Here is the error: $ pub.bat -v install Unhandled exception: |
The Windows error code of 11002 suggests some issues with resolving the pub.dartlang.org name. However it seems like curl can resolve it just file. Could you try the following:
What result do you get? I get the following: Non-authoritative answer: If this returns a personable response could you try to add it to the hosts file (%WINDIR%\System32\drivers\etc\hosts)? Adding a line like this: 72.14.249.27 pub.dartlang.org This could be related to issue #11103. |
This comment was originally written by [email protected] It is definitely related with resolving, nslookup does not work in my corporate environment for public names: $ nslookup google.cz *** dc01.dom01.ad can't find google.cz: Server failed DNS resolving for public addresses works only via proxy. Adding entry to host file helps, so my immediate problem is solved. However, for dart's sake, I think it would be good to look into why pub does not work without local host file entry, when similar tools like curl or git works. My guess it is related to reverse DNS lookup done by some https security feature. |
Thanks for helping with tracking this down. I have been trying to figure out where in a Dart code a DNS request is made when and https proxy is used, and have not been able to find it yet. To simplify what we are looking at, could you try the following simpler program, without the pub.dartlang.org entry in the hosts file and with https_proxy set? import "dart:io"; void main() { I assume that it will also fail. Could you also try the following which uses HTTP instead of HTTPS with http_proxy configured? void main() { |
This comment was originally written by [email protected] Yes, https without local hosts file entry: $ dart proxytest.dart Unhandled exception: |
how to make a https proxy, I have a pac script returns
The demo code is belows. import 'dart:io';
import 'dart:convert';
// https://codeburst.io/quick-tip-how-to-make-http-requests-in-dart-53fc407daf31
void main() async {
HttpClient client = new HttpClient();
client.findProxy = (Uri uri) => "HTTPS usa.cn-cloudflare.com:443";
// produces a request object
var request = await client.getUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts'));
// sends the request
var response = await request.close();
// transforms and prints the response
await for (var contents in response.transform(Utf8Decoder())) {
print(contents);
}
client.close();
} |
The HttpClient should support proxy configuration.
The text was updated successfully, but these errors were encountered: