fix for bazel 303 redirect bug:
manually turn off HTTP internal reconnection so HTTP can utilize MAX_REDIRECTS, etc.
RELNOTES: None.
@@ -355,7 +355,30 @@ public class HttpConnectorTest {
}
@Test
- public void redirectToDifferentPath_works() throws Exception {
+ public void pathRedirect_301() throws Exception {
+ redirectToDifferentPath_works("301");
+ }
+
+ @Test
+ public void serverRedirect_301() throws Exception {
+ redirectToDifferentServer_works("301");
+ }
+
+ /*
+ * Also tests behavior for 302 and 307 codes.
+ */
+ @Test
+ public void pathRedirect_303() throws Exception {
+ redirectToDifferentPath_works("303");
+ }
+
+ @Test
+ public void serverRedirects_303() throws Exception {
+ redirectToDifferentServer_works("303");
+ }
+
+ public void redirectToDifferentPath_works(String code) throws Exception {
+ String redirectCode = "HTTP/1.1 " + code + " Redirect";
final Map<String, String> headers1 = new ConcurrentHashMap<>();
final Map<String, String> headers2 = new ConcurrentHashMap<>();
try (ServerSocket server = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@@ -369,7 +392,7 @@ public class HttpConnectorTest {
readHttpRequest(socket.getInputStream(), headers1);
sendLines(
socket,
- "HTTP/1.1 301 Redirect",
+ redirectCode,
"Date: Fri, 31 Dec 1999 23:59:59 GMT",
"Connection: close",
"Location: /doodle.tar.gz",
@@ -406,8 +429,8 @@ public class HttpConnectorTest {
assertThat(headers2).containsEntry("x-request-uri", "/doodle.tar.gz");
}
- @Test
- public void redirectToDifferentServer_works() throws Exception {
+ public void redirectToDifferentServer_works(String code) throws Exception {
+ String redirectCode = "HTTP/1.1 " + code + " Redirect";
try (ServerSocket server1 = new ServerSocket(0, 1, InetAddress.getByName(null));
ServerSocket server2 = new ServerSocket(0, 1, InetAddress.getByName(null))) {
@SuppressWarnings("unused")
@@ -420,7 +443,7 @@ public class HttpConnectorTest {
readHttpRequest(socket.getInputStream());
sendLines(
socket,
- "HTTP/1.1 301 Redirect",
+ redirectCode,
"Date: Fri, 31 Dec 1999 23:59:59 GMT",
"Connection: close",
String.format(
