好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

获取HTTP重定向的地址列表

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.com'));
  var response = await request.close();
  List<RedirectInfo> redirects = response.redirects;
  redirects.forEach((redirect) {
    print(redirect.location); // Prints 'http://www.google.com'.
  });
} 

查看更多关于获取HTTP重定向的地址列表的详细内容...

  阅读:53次

上一篇: 元数据 - Metadata

下一篇:注释 - Comments