Add latest url to the response to make detection of a redirect possible

Will be latest one in this commit because there's need to check the
history of redirects as of now.
This commit is contained in:
Mauricio Colli
2020-02-29 17:57:23 -03:00
committed by TobiGr
parent 3441946bea
commit 5edd774fc4
2 changed files with 19 additions and 3 deletions

View File

@@ -99,8 +99,9 @@ public class DownloaderTestImpl extends Downloader {
final int responseCode = connection.getResponseCode();
final String responseMessage = connection.getResponseMessage();
final Map<String, List<String>> responseHeaders = connection.getHeaderFields();
final String latestUrl = connection.getURL().toString();
return new Response(responseCode, responseMessage, responseHeaders, response.toString());
return new Response(responseCode, responseMessage, responseHeaders, response.toString(), latestUrl);
} catch (Exception e) {
final int responseCode = connection.getResponseCode();
@@ -112,7 +113,8 @@ public class DownloaderTestImpl extends Downloader {
if (responseCode == 429) {
throw new ReCaptchaException("reCaptcha Challenge requested", url);
} else if (responseCode != -1) {
return new Response(responseCode, connection.getResponseMessage(), connection.getHeaderFields(), null);
final String latestUrl = connection.getURL().toString();
return new Response(responseCode, connection.getResponseMessage(), connection.getHeaderFields(), null, latestUrl);
}
throw new IOException("Error occurred while fetching the content", e);