Making TomcatBaseTest.getUrl() work for get requests that return 404 responses
authortimw <timw@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 6 Oct 2010 08:36:20 +0000 (08:36 +0000)
committertimw <timw@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 6 Oct 2010 08:36:20 +0000 (08:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1004927 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/catalina/startup/TomcatBaseTest.java

index 5c78c3e..3ff74ef 100644 (file)
@@ -191,21 +191,23 @@ public abstract class TomcatBaseTest extends TestCase {
             Map<String, List<String>> head = connection.getHeaderFields();
             resHead.putAll(head);
         }
-        InputStream is = connection.getInputStream();
-        BufferedInputStream bis = null;
-        try {
-            bis = new BufferedInputStream(is);
-            byte[] buf = new byte[2048];
-            int rd = 0;
-            while((rd = bis.read(buf)) > 0) {
-                out.append(buf, 0, rd);
-            }
-        } finally {
-            if (bis != null) {
-                try {
-                    bis.close();
-                } catch (IOException e) {
-                    // Ignore
+        if (rc == HttpServletResponse.SC_OK) {
+            InputStream is = connection.getInputStream();
+            BufferedInputStream bis = null;
+            try {
+                bis = new BufferedInputStream(is);
+                byte[] buf = new byte[2048];
+                int rd = 0;
+                while((rd = bis.read(buf)) > 0) {
+                    out.append(buf, 0, rd);
+                }
+            } finally {
+                if (bis != null) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+                        // Ignore
+                    }
                 }
             }
         }