Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Unified Diff: sdk/lib/io/secure_socket.dart

Issue 2950413002: Added timeout parameter to RawSecureSocket and SecureSocket connect methods. Also updated CHANGELOG… (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/secure_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index 7f2e8cccfb6a621b12da4f3288750b2bc53d08a0..096318b72038ee852704cddcddb2a6f5e4d37fd2 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -33,16 +33,25 @@ abstract class SecureSocket implements Socket {
* order of preference) to use during the ALPN protocol negogiation with the
* server. Example values are "http/1.1" or "h2". The selected protocol
* can be obtained via [SecureSocket.selectedProtocol].
+ *
+ * The argument [timeout] is used to specify the maximum allowed time to wait
+ * for a connection to be established. If [timeout] is longer than the system
+ * level timeout duration, a timeout may occur sooner than specified in
+ * [timeout]. On timeout, a [SocketException] is thrown and all ongoing
+ * connection attempts to [host] are cancelled.
+
*/
static Future<SecureSocket> connect(host, int port,
{SecurityContext context,
bool onBadCertificate(X509Certificate certificate),
- List<String> supportedProtocols}) {
+ List<String> supportedProtocols,
+ Duration timeout}) {
return RawSecureSocket
.connect(host, port,
context: context,
onBadCertificate: onBadCertificate,
- supportedProtocols: supportedProtocols)
+ supportedProtocols: supportedProtocols,
+ timeout: timeout)
.then((rawSocket) => new SecureSocket._(rawSocket));
}
@@ -194,10 +203,11 @@ abstract class RawSecureSocket implements RawSocket {
static Future<RawSecureSocket> connect(host, int port,
{SecurityContext context,
bool onBadCertificate(X509Certificate certificate),
- List<String> supportedProtocols}) {
+ List<String> supportedProtocols,
+ Duration timeout}) {
_RawSecureSocket._verifyFields(
host, port, false, false, false, onBadCertificate);
- return RawSocket.connect(host, port).then((socket) {
+ return RawSocket.connect(host, port, timeout: timeout).then((socket) {
return secure(socket,
context: context,
onBadCertificate: onBadCertificate,
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/secure_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698