equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @bug 4380568 7095949 |
26 * @bug 4380568 7095949 |
|
27 * @library /test/lib |
27 * @summary HttpURLConnection does not support 307 redirects |
28 * @summary HttpURLConnection does not support 307 redirects |
28 */ |
29 */ |
29 import java.io.*; |
30 import java.io.*; |
30 import java.net.*; |
31 import java.net.*; |
|
32 |
|
33 import jdk.test.lib.net.URIBuilder; |
31 |
34 |
32 class RedirServer extends Thread { |
35 class RedirServer extends Thread { |
33 |
36 |
34 static final int TIMEOUT = 10 * 1000; |
37 static final int TIMEOUT = 10 * 1000; |
35 |
38 |
98 } |
101 } |
99 }; |
102 }; |
100 |
103 |
101 public class Redirect307Test { |
104 public class Redirect307Test { |
102 public static void main(String[] args) throws Exception { |
105 public static void main(String[] args) throws Exception { |
103 ServerSocket sock = new ServerSocket(0); |
106 ServerSocket sock = new ServerSocket(0, 0, InetAddress.getLoopbackAddress()); |
104 int port = sock.getLocalPort(); |
107 int port = sock.getLocalPort(); |
105 RedirServer server = new RedirServer(sock); |
108 RedirServer server = new RedirServer(sock); |
106 server.start(); |
109 server.start(); |
107 |
110 |
108 URL url = new URL("http://localhost:" + port); |
111 URL url = URIBuilder.newBuilder() |
|
112 .scheme("http") |
|
113 .loopback() |
|
114 .port(port) |
|
115 .toURL(); |
109 URLConnection conURL = url.openConnection(); |
116 URLConnection conURL = url.openConnection(); |
110 conURL.setDoInput(true); |
117 conURL.setDoInput(true); |
111 conURL.setAllowUserInteraction(false); |
118 conURL.setAllowUserInteraction(false); |
112 conURL.setUseCaches(false); |
119 conURL.setUseCaches(false); |
113 |
120 |