dio 0.0.2 dio: ^0.0.2 copied to clipboard
A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData and soon on.
import 'dart:async';
import 'dart:io';
import 'package:dio/dio.dart';
main() async {
var dio = new Dio();
dio.options.baseUrl = "http://www.dtworkroom.com/doris/1/2.0.0/";
dio.options.headers = {
'XX': '8'
};
// dio.httpClient.findProxy = (uri) {
// //proxy all request to localhost:8888
// return "PROXY localhost:8888";
// };
dio.interceptor.request.onSend = (Options options) async {
// return ds.resolve(new Response(data:"xxx"));
// return ds.reject(new Err(message: "eh"));
return options;
};
Response<String> response= await dio.get("https://www.google.com/");
print(response.data);
response=await dio.download("https://www.google.com/","./xx.html",onProgress: (received,total){
print('$received,$total');
});
// ds.get("/test",data:{'aa':8}).catchError((Err err){
// print(err);
// });
print(response);
//FormData.boundary = "----------------------------272264345542536768869165";
FormData formData = new FormData.from({
"name": "wendux /r/n xxx \r\n \$%#@ ",
"age": 25,
"file": new UploadFileInfo(new File("./example/upload.txt"), "upload.txt")
});
//
// response = await dio.post("/token", data: formData);
// print(response);
//Response response= await ds.post("/test",data:formData);
//print(response.toString());
//new Timer(new Duration(seconds: 2),()=>ds.unlock());
//Response response= await ds.get("/test",data:{'aa':8});
//print(response.data);
}