Upon sending login data to a remote URL, the website returns a 302 along with the proper login Cookies. When processing it with http or HttpClient, the status code 302 is processed as good, however with Dio it's considered as an error.
How to make Dio handle the HTTP 302 code as a regular HTTP code and not an error ?
Code
Dio dio = new Dio();
dio.options.contentType = ContentType('application','x-www-form-urlencoded');
dio.post(urlLogin, data: data).then((Response resp){
print('-----Login-----');
List<String> headers = resp.headers['set-cookie'];
headers.forEach((h) => print(h));
});
Stack Trace
Unhandled exception:
DioError [DioErrorType.RESPONSE]: Http status error [302]
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:391:30)
#4 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#5 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)