Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11249)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11250)
@@ -6,4 +6,5 @@
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -190,4 +191,5 @@
         private boolean uncompress;
         private boolean uncompressAccordingToContentDisposition;
+        private String responseData = null;
 
         private Response(HttpURLConnection connection, ProgressMonitor monitor) throws IOException {
@@ -198,4 +200,22 @@
             this.responseCode = connection.getResponseCode();
             this.responseMessage = connection.getResponseMessage();
+            if (this.responseCode >= 300) {
+                String contentType = getContentType();
+                if (contentType == null || (
+                        contentType.contains("text") ||
+                        contentType.contains("html") ||
+                        contentType.contains("xml"))
+                        ) {
+                    String content = this.fetchContent();
+                    if (content == null || content.isEmpty()) {
+                        Main.debug("Server did not return any body");
+                    } else {
+                        Main.debug("Response body: ");
+                        Main.debug(this.fetchContent());
+                    }
+                } else {
+                    Main.debug("Server returned content: {0} of length: {1}. Not printing.", contentType, this.getContentLength());
+                }
+            }
         }
 
@@ -264,4 +284,7 @@
                 Main.debug(ioe);
                 in = connection.getErrorStream();
+                if (in == null) {
+                    in = new ByteArrayInputStream(new byte[]{});
+                }
             }
             if (in != null) {
@@ -306,9 +329,11 @@
          * @throws IOException if any I/O error occurs
          */
-        @SuppressWarnings("resource")
-        public String fetchContent() throws IOException {
-            try (Scanner scanner = new Scanner(getContentReader()).useDelimiter("\\A")) {
-                return scanner.hasNext() ? scanner.next() : "";
-            }
+        public synchronized String fetchContent() throws IOException {
+            if (responseData == null) {
+                try (Scanner scanner = new Scanner(getContentReader()).useDelimiter("\\A")) { // \A - beginning of input
+                    responseData = scanner.hasNext() ? scanner.next() : "";
+                }
+            }
+            return responseData;
         }
 
