In my project I send simple request for authorization :
http.Response response = await http.get(url, headers: headers);
In response I has cookieID and other information, but I doesnt receive redirect url.
How I can take him?
In my project I send simple request for authorization :
http.Response response = await http.get(url, headers: headers);
In response I has cookieID and other information, but I doesnt receive redirect url.
How I can take him?
As jamesdlin has mentioned above and this github issue mentions, http has redirects set to true by default. To avoid redirect followRedirects needs to be set to false. The redirectUri can be fetched as follows:
import 'package:http/http.dart' as http;
http.Request req = http.Request("Get", Uri.parse(YOUR_URL_HERE))..followRedirects = false;
http.Client baseClient = http.Client();
http.StreamedResponse response = await baseClient.send(req);
Uri redirectUri = Uri.parse(response.headers['location'])
By default, package:http and the underlying HttpClient will follow HTTP redirects automatically.
If you don't want this, then you can disable it by setting HttpClientRequest.followRedirects to false.
package:http exposes this through BaseRequest.followRedirects.