Package
dio, cookie_manager
Version
2.1.1
Output of flutter doctor -v
No response
Dart Version
No response
Steps to Reproduce
final dio = Dio();
final dir = await getApplicationSupportDirectory();
final cookieJar = PersistCookieJar(storage: FileStorage(join(dir.path, "cookies")));
dio.interceptors.add(CookieManager(cookieJar));
dio.get("http://site1") ; // This is a 302 redirect url. The redirected site2 url will return the set-cookie response header
Expected Result
The cookie will be saved to site2
Actual Result
The cookie is saved to the original url, ie site1, resulting in no cookie being carried in subsequent requests.
So I checked the source code cookie_mgr.dart, Should response.requestOptions.uri be changed to response.realUri?
Future<void> _saveCookies(Response response) async {
final setCookies = response.headers[HttpHeaders.setCookieHeader];
if (setCookies != null) {
final cookies = setCookies
.map((str) => str.split(_setCookieReg))
.expand((element) => element);
await cookieJar.saveFromResponse(
response.requestOptions.uri, // Should this be changed to response.realUri ?
cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(),
);
}
}
Package
dio, cookie_manager
Version
2.1.1
Output of
flutter doctor -vNo response
Dart Version
No response
Steps to Reproduce
Expected Result
The cookie will be saved to site2
Actual Result
The cookie is saved to the original url, ie site1, resulting in no cookie being carried in subsequent requests.
So I checked the source code cookie_mgr.dart, Should response.requestOptions.uri be changed to response.realUri?