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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。