IDEA-CR-999 (connection closing)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 26 Nov 2014 11:47:46 +0000 (12:47 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 26 Nov 2014 11:47:46 +0000 (12:47 +0100)
platform/platform-impl/src/com/intellij/util/io/HttpRequests.java

index 8051801cc8f3d8a5f199867bdead89f7559d433a..3ba14daca8004c5f55c69666db14cdf377de6f4f 100644 (file)
@@ -172,20 +172,18 @@ public final class HttpRequests {
 
       if (connection instanceof HttpURLConnection) {
         int responseCode = ((HttpURLConnection)connection).getResponseCode();
+
         if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_MODIFIED) {
+          ((HttpURLConnection)connection).disconnect();
+
           if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
             url = connection.getHeaderField("Location");
-          }
-          else {
-            url = null;
+            if (url != null) {
+              continue;
+            }
           }
 
-          if (url == null) {
-            throw new IOException(IdeBundle.message("error.connection.failed.with.http.code.N", responseCode));
-          }
-
-          ((HttpURLConnection)connection).disconnect();
-          continue;
+          throw new IOException(IdeBundle.message("error.connection.failed.with.http.code.N", responseCode));
         }
       }