dart-sdk/sdk/lib/_http/embedder_config.dart
Alexander Aprelev 8d54a30825 [io/http] Introduce callback that embedder can override to provide custom HTTPClient connection validation.
For example, this can be used to ban insecure http connections, force use of https ones - see https://github.com/flutter/engine/pull/26226.

Issue https://github.com/flutter/flutter/issues/69685
Issue https://github.com/flutter/flutter/issues/54448

Change-Id: Id81aeae9aff0d469ac6f911e4e502b39ce9558bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200524
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-05-20 15:17:52 +00:00

22 lines
895 B
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of dart._http;
/// Embedder-specific `dart:_http` configuration.
/// Embedder hook for intercepting HTTP connections.
///
/// The [HttpClient] will call this function as a connection to a given [Uri]
/// is being established.
///
/// The embedder can provide its own implementation to,
/// for example, confirm whether such a connection should be allowed.
/// If the connection is not allowed, this method can throw an [Error],
/// which should then provide enough information to say why the connection
/// was refused.
/// If this function returns normally, the connection attempt will proceed.
@pragma('vm:entry-point')
void Function(Uri) _httpConnectionHook = (_) {};