mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
HttpRequests: disable java's followRedirects
This commit is contained in:
@@ -501,12 +501,15 @@ public final class HttpRequests {
|
||||
}
|
||||
|
||||
if (connection instanceof HttpURLConnection) {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection)connection;
|
||||
httpURLConnection.setInstanceFollowRedirects(false);
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("connecting to " + url);
|
||||
int responseCode = ((HttpURLConnection)connection).getResponseCode();
|
||||
int responseCode = httpURLConnection.getResponseCode();
|
||||
if (LOG.isDebugEnabled()) LOG.debug("response: " + responseCode);
|
||||
|
||||
if (responseCode < 200 || responseCode >= 300 && responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
((HttpURLConnection)connection).disconnect();
|
||||
httpURLConnection.disconnect();
|
||||
|
||||
if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
request.myUrl = url = connection.getHeaderField("Location");
|
||||
|
||||
Reference in New Issue
Block a user