You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/02/02 21:41:59 UTC
svn commit: r1823006 -
/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org