-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature request: HttpClient should accept existing Socket objects to establish the connection #43277
Comments
|
@zichangg can you please elaborate the problem? The one I am getting is that if you are unable to use existing sockets for eg. you are getting error wile connecting with locally hosted API and getting Socket Exception Error. Then to fix those issue follow the steps given below:
It worked for me. |
I have a design proposal to tackle this issue. Any feedback would be welcome: |
I'm going to mark this as fixed by a0aeed9 - if that is not sufficient, please reopen. |
I'm trying to use the solution added on a0aeed9 to use a SSL HTTP(S) proxy. I have built SDK revision 9863451 with d6a4eda reverted. final client = IOClient(HttpClient()
..findProxy = ((_) => 'PROXY username:password@au755.nordvpn.com:89')
..connectionFactory = ((url, proxyHost, proxyPort) {
// I'm assuming a SSL proxy is provided here for the sake of simplicity.
return SecureSocket.startConnect(proxyHost!, proxyPort!);
}));
await client.read(Uri.parse('https://dart.dev')) This fails with the following error:
The error happens after the authentication stage; if the credentials are wrong, I receive an HTTP 407 error from the proxy server. It's also worth noting that replacing |
Hi @hacker1024 - if you change the code to not use final client = IOClient(HttpClient()
..findProxy = ((_) => 'PROXY username:password@au755.nordvpn.com:89');
await client.read(Uri.parse('https://dart.dev')) If so, could you file another bug to track this issue? |
@brianquinlan It does not. See: #43876. |
HttpClient
is not able to reuse existingsockets
. It will always use_SecureSocket
or_Socket
(dart:io implementation ofSecureSocket
/Socket
). Self-writtenSocket
s are not allowed. Users will have to useIOOverride
as a workaround.With this feature, it grants the freedom to users to choose the underlying connection. e.g. Unix domain sockets, which was supported a while ago, can be easily installed to
HttpClient
.It also potential boosts the performance if used properly.
The text was updated successfully, but these errors were encountered: