24
24
/**
25
25
* @test
26
26
* @bug 8042622
27
+ * @library /test/lib
27
28
* @summary Check for CRL results in IllegalArgumentException "white space not allowed"
28
29
* @modules jdk.httpserver
29
30
* @run main/othervm Test2
38
39
import java .security .*;
39
40
import javax .security .auth .callback .*;
40
41
import javax .net .ssl .*;
42
+ import jdk .test .lib .net .URIBuilder ;
41
43
42
44
public class Test2 {
43
45
@@ -63,7 +65,7 @@ public CacheRequest put(URI uri, URLConnection c) throws IOException {
63
65
64
66
static int port ;
65
67
66
- static String urlstring , redirstring ;
68
+ static URL url , redir ;
67
69
68
70
public static void main (String [] args ) throws Exception {
69
71
Handler handler = new Handler ();
@@ -78,10 +80,21 @@ public static void main (String[] args) throws Exception {
78
80
server .setExecutor (executor );
79
81
server .start ();
80
82
81
- urlstring = "http://127.0.0.1:" + Integer .toString (port )+"/test/foo" ;
82
- redirstring = urlstring + "/redirect/bar" ;
83
+ url = URIBuilder .newBuilder ()
84
+ .scheme ("http" )
85
+ .loopback ()
86
+ .port (port )
87
+ .path ("/test/foo" )
88
+ .toURLUnchecked ();
89
+ System .out .println ("URL: " + url );
90
+ redir = URIBuilder .newBuilder ()
91
+ .scheme ("http" )
92
+ .loopback ()
93
+ .port (port )
94
+ .path ("/test/foo/redirect/bar" )
95
+ .toURLUnchecked ();
96
+ System .out .println ("Redir URL: " + redir );
83
97
84
- URL url = new URL (urlstring );
85
98
HttpURLConnection urlc = (HttpURLConnection )url .openConnection ();
86
99
urlc .addRequestProperty ("X-Foo" , "bar" );
87
100
urlc .setInstanceFollowRedirects (true );
@@ -114,7 +127,7 @@ public void handle (HttpExchange t)
114
127
Headers rmap = t .getResponseHeaders ();
115
128
invocation ++;
116
129
if (invocation == 1 ) {
117
- rmap .add ("Location" , redirstring );
130
+ rmap .add ("Location" , redir . toString () );
118
131
while (is .read () != -1 ) ;
119
132
is .close ();
120
133
System .out .println ("sending response" );
0 commit comments