fix: java.net.URLConnection not following redirects from http to https

This commit is contained in:
Tobi Schäfer 2020-04-12 19:08:02 +02:00
parent df3af8fab1
commit 8edc9db372

View file

@ -57,6 +57,8 @@ helma.Http = function() {
"socket": 0
};
var maxResponseSize = null;
var maxTries = 5;
var currentTries = 0;
var responseHandler = function(connection, result) {
var input;
@ -556,6 +558,14 @@ helma.Http = function() {
content: null,
}
// java.net.URLConnection does not follow redirects from http to https
// See https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4620571
if (followRedirects && [301, 303].contains(result.code) && result.location) {
currentTries += 1;
if (currentTries >= maxTries) throw new Error('Too many redirects');
return this.getUrl(result.location, opt);
}
// parse all "Set-Cookie" header fields into an array of
// helma.Http.Cookie instances
var setCookies = conn.getHeaderFields().get("Set-Cookie");