- HttpSocket
var server = await HttpServer.bind(
InternetAddress.loopbackIPv4,
4040,
);
print('Listening on localhost:${server.port}');
await for (HttpRequest request in server) {
request.response
..write('Hello, world!')
..close();
}
- HttpClient
HttpClient httpClient = HttpClient();
HttpClientRequest request =
await httpClient.getUrl(Uri.parse("http://localhost:4444"));
HttpClientResponse response = await request.close();
var resData = await response.transform(utf8.decoder).join();
httpClient.close();
标签:HttpSocket,await,request,dart,close,httpClient,HttpClient
From: https://www.cnblogs.com/sqmw/p/17032165.html