Author: markt
Date: Fri Feb  2 21:41:59 2018
New Revision: 1823006

URL: http://svn.apache.org/viewvc?rev=1823006&view=rev
Log:
Add option for test to control if redirects are followed or not

Modified:
    tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java

Modified: tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1823006&r1=1823005&r2=1823006&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Fri Feb  
2 21:41:59 2018
@@ -622,38 +622,48 @@ public abstract class TomcatBaseTest ext
         return out;
     }
 
-    public static int getUrl(String path, ByteChunk out,
-            Map<String, List<String>> resHead) throws IOException {
+    public static int getUrl(String path, ByteChunk out, Map<String, 
List<String>> resHead)
+            throws IOException {
         return getUrl(path, out, null, resHead);
     }
 
-    public static int headUrl(String path, ByteChunk out,
-            Map<String, List<String>> resHead) throws IOException {
+    public static int getUrl(String path, ByteChunk out, boolean 
followRedirects)
+            throws IOException {
+        return methodUrl(path, out, DEFAULT_CLIENT_TIMEOUT_MS, null, null, 
"GET", followRedirects);
+    }
+
+    public static int headUrl(String path, ByteChunk out, Map<String, 
List<String>> resHead)
+            throws IOException {
         return methodUrl(path, out, DEFAULT_CLIENT_TIMEOUT_MS, null, resHead, 
"HEAD");
     }
 
-    public static int getUrl(String path, ByteChunk out,
-            Map<String, List<String>> reqHead,
+    public static int getUrl(String path, ByteChunk out, Map<String, 
List<String>> reqHead,
             Map<String, List<String>> resHead) throws IOException {
         return getUrl(path, out, DEFAULT_CLIENT_TIMEOUT_MS, reqHead, resHead);
     }
 
     public static int getUrl(String path, ByteChunk out, int readTimeout,
-            Map<String, List<String>> reqHead,
-            Map<String, List<String>> resHead) throws IOException {
+            Map<String, List<String>> reqHead, Map<String, List<String>> 
resHead)
+            throws IOException {
         return methodUrl(path, out, readTimeout, reqHead, resHead, "GET");
     }
 
     public static int methodUrl(String path, ByteChunk out, int readTimeout,
-            Map<String, List<String>> reqHead,
-            Map<String, List<String>> resHead,
-            String method) throws IOException {
+            Map<String, List<String>> reqHead, Map<String, List<String>> 
resHead, String method)
+            throws IOException {
+        return methodUrl(path, out, readTimeout, reqHead, resHead, method, 
true);
+    }
+
+    public static int methodUrl(String path, ByteChunk out, int readTimeout,
+                Map<String, List<String>> reqHead, Map<String, List<String>> 
resHead, String method,
+                boolean followRedirects) throws IOException {
 
         URL url = new URL(path);
         HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
         connection.setUseCaches(false);
         connection.setReadTimeout(readTimeout);
         connection.setRequestMethod(method);
+        connection.setInstanceFollowRedirects(followRedirects);
         if (reqHead != null) {
             for (Map.Entry<String, List<String>> entry : reqHead.entrySet()) {
                 StringBuilder valueList = new StringBuilder();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to