Use the HttpClient class in the 'dart:io' library to make a request, and use the Response redirects property to get a list of the redirects.
import "dart:io" show HttpClient, RedirectInfo;
main() async {
var client = new HttpClient();
var request = await client.getUrl(Uri.parse('http://google测试数据'));
var response = await request.close();
List<RedirectInfo> redirects = response.redirects;
redirects.forEach((redirect) {
print(redirect.location); // Prints 'http://HdhCmsTestgoogle测试数据'.
});
}
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did129480