dart:io
库中HttpOverrides
类的用法介绍如下。
此类有助于使用模拟实现覆盖HttpClient。它应该由客户端代码中的另一个类扩展,并具有构建模拟实现的覆盖。此基类中的实现默认为实际的HttpClient 实现。例如:
// An implementation of the HttpClient interface
class MyHttpClient implements HttpClient {
MyHttpClient(SecurityContext? c);
@override
noSuchMethod(Invocation invocation) {
// your implementation here
}
}
void main() {
HttpOverrides.runZoned(() {
// Operations will use MyHttpClient instead of the real HttpClient
// implementation whenever HttpClient is used.
}, createHttpClient: (SecurityContext? c) => MyHttpClient(c));
}
相关用法
- Dart HttpRequest.postFormData用法及代码示例
- Dart HttpClient.findProxy用法及代码示例
- Dart HttpClientRequest用法及代码示例
- Dart HttpServer.defaultResponseHeaders用法及代码示例
- Dart HttpClient用法及代码示例
- Dart HttpRequest.request用法及代码示例
- Dart HttpClient.findProxyFromEnvironment用法及代码示例
- Dart HttpClientResponse用法及代码示例
- Dart HttpDate.parse用法及代码示例
- Dart HttpClient.connectionFactory用法及代码示例
- Dart HttpRequest用法及代码示例
- Dart HttpClientRequest.followRedirects用法及代码示例
- Dart HttpHeaders用法及代码示例
- Dart HttpClient.keyLog用法及代码示例
- Dart HttpServer用法及代码示例
- Dart HttpRequest.getString用法及代码示例
- Dart HttpRequest构造函数用法及代码示例
- Dart HttpClientRequest.abort用法及代码示例
- Dart HttpResponse用法及代码示例
- Dart HtmlCollection.last用法及代码示例
- Dart HtmlEscape用法及代码示例
- Dart HtmlEscapeMode用法及代码示例
- Dart HtmlCollection.elementAt用法及代码示例
- Dart HtmlCollection.length用法及代码示例
- Dart HtmlDocument.registerElement2用法及代码示例
注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 HttpOverrides class。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。