From 8a6e2998f1e15539f6e0fc2bc4570e9876dd6343 Mon Sep 17 00:00:00 2001 From: Ivan Chirkov Date: Wed, 26 Jul 2017 23:58:17 +0200 Subject: [PATCH] HttpRequests: disable java's followRedirects --- .../src/com/intellij/util/io/HttpRequests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/io/HttpRequests.java b/platform/platform-api/src/com/intellij/util/io/HttpRequests.java index 7ac69950e284..dccb46362eb6 100644 --- a/platform/platform-api/src/com/intellij/util/io/HttpRequests.java +++ b/platform/platform-api/src/com/intellij/util/io/HttpRequests.java @@ -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");