]> WPIA git - gigi.git/commitdiff
Testcases more verbose on server fail (with illegal charset)
authorFelix Dörre <felix@dogcraft.de>
Thu, 24 Jul 2014 22:58:56 +0000 (00:58 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 24 Jul 2014 23:44:49 +0000 (01:44 +0200)
tests/org/cacert/gigi/testUtils/IOUtils.java

index b7452d2a4422d8acc1fd18d6d8b6fc54fa2e6c64..2db46f87832bb8acfeb2d90fb571b6cb22ec6cab 100644 (file)
@@ -4,6 +4,7 @@ import java.io.CharArrayWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.net.HttpURLConnection;
 import java.net.URLConnection;
 
 public class IOUtils {
@@ -14,6 +15,10 @@ public class IOUtils {
        public static String readURL(URLConnection in) {
                try {
                        if (!in.getContentType().equals("text/html; charset=UTF-8")) {
+                               if (in instanceof HttpURLConnection && ((HttpURLConnection) in).getResponseCode() != 200) {
+                                       System.err
+                                               .println(readURL(new InputStreamReader(((HttpURLConnection) in).getErrorStream(), "UTF-8")));
+                               }
                                throw new Error("Unrecognized content-type: " + in.getContentType());
                        }
                        return readURL(new InputStreamReader(in.getInputStream(), "UTF-8"));