equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 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. |
26 import java.io.IOException; |
26 import java.io.IOException; |
27 import java.io.OutputStream; |
27 import java.io.OutputStream; |
28 import java.net.*; |
28 import java.net.*; |
29 import java.util.List; |
29 import java.util.List; |
30 import java.util.Map; |
30 import java.util.Map; |
31 import java.util.concurrent.Executors; |
31 import static java.net.Proxy.NO_PROXY; |
32 |
32 |
33 /* |
33 /* |
34 * @test |
34 * @test |
35 * @bug 7169142 |
35 * @bug 7169142 |
|
36 * @key intermittent |
36 * @modules jdk.httpserver |
37 * @modules jdk.httpserver |
37 * @summary CookieHandler does not work with localhost |
38 * @summary CookieHandler does not work with localhost. This requires |
|
39 * binding to the wildcard address and might fail intermittently |
|
40 * due to port reuse issues. |
38 * @run main/othervm LocalHostCookie |
41 * @run main/othervm LocalHostCookie |
39 */ |
42 */ |
40 public class LocalHostCookie { |
43 public class LocalHostCookie { |
41 |
44 |
42 public static void main(String[] args) throws Exception { |
45 public static void main(String[] args) throws Exception { |
47 Server s = null; |
50 Server s = null; |
48 try { |
51 try { |
49 s = new Server(); |
52 s = new Server(); |
50 s.startServer(); |
53 s.startServer(); |
51 URL url = new URL("http","localhost", s.getPort(), "/"); |
54 URL url = new URL("http","localhost", s.getPort(), "/"); |
52 HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); |
55 HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(NO_PROXY); |
53 urlConnection.setRequestMethod("GET"); |
56 urlConnection.setRequestMethod("GET"); |
54 urlConnection.setDoOutput(true); |
57 urlConnection.setDoOutput(true); |
55 urlConnection.connect(); |
58 urlConnection.connect(); |
56 urlConnection.getInputStream(); |
59 urlConnection.getInputStream(); |
57 |
60 |
124 os.close(); |
127 os.close(); |
125 } |
128 } |
126 } |
129 } |
127 } |
130 } |
128 } |
131 } |
129 |
|