@@ -9,8 +9,8 @@ A macOS/iOS library that provides access to the
99Using the [ Foundation URL Loading System] [ ] , rather than the socket-based
1010[ dart: io HttpClient] [ ] implementation, has several advantages:
1111
12- 1 . It automatically supports iOS/macOS platform features such VPNs and HTTP
13- proxies.
12+ 1 . It automatically supports iOS/macOS platform features such as VPNs and HTTP
13+ proxies.
14142 . It supports many more configuration options such as only allowing access
1515 through WiFi and blocking cookies.
16163 . It supports more HTTP features such as HTTP/3 and custom redirect handling.
@@ -24,6 +24,8 @@ This approach allows the same HTTP code to be used on all platforms, while
2424still allowing platform-specific setup.
2525
2626``` dart
27+ import 'dart:io';
28+
2729import 'package:cupertino_http/cupertino_http.dart';
2830import 'package:http/http.dart';
2931import 'package:http/io_client.dart';
@@ -43,6 +45,8 @@ void main() async {
4345 'www.googleapis.com',
4446 '/books/v1/volumes',
4547 {'q': 'HTTP', 'maxResults': '40', 'printType': 'books'}));
48+
49+ httpClient.close();
4650}
4751```
4852
@@ -81,8 +85,8 @@ final url = Uri.https(
8185final session = URLSession.sharedSession();
8286final task = session.dataTaskWithCompletionHandler(URLRequest.fromUrl(url),
8387 (data, response, error) {
84- if (error == null && response! .statusCode == 200) {
85- print(data!.bytes );
88+ if (error == null && response is HTTPURLResponse && response .statusCode == 200) {
89+ print(data!.toList() );
8690 }
8791});
8892task.resume();
0 commit comments