test/jdk/com/sun/net/httpserver/bugs/B6373555.java
changeset 55309 8081b181bba8
parent 54314 46cf212cdcca
equal deleted inserted replaced
55308:871bc449ce06 55309:8081b181bba8
     1 /*
     1 /*
     2  * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2006, 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.
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug 6373555
    26  * @bug 6373555
    27  * @library /test/lib
    27  * @library /test/lib
    28  * @summary HTTP Server failing to answer client requests
    28  * @summary HTTP Server failing to answer client requests
       
    29  * @run main B6373555
       
    30  * @run main/othervm -Djava.net.preferIPv6Addresses=true B6373555
    29  */
    31  */
    30 
    32 
    31 import java.net.*;
    33 import java.net.*;
    32 import java.io.*;
    34 import java.io.*;
    33 import java.util.*;
    35 import java.util.*;
   103                     .loopback()
   105                     .loopback()
   104                     .port(port)
   106                     .port(port)
   105                     .path("/test")
   107                     .path("/test")
   106                     .toURLUnchecked();
   108                     .toURLUnchecked();
   107                 System.out.println("URL: " + url);
   109                 System.out.println("URL: " + url);
   108                 HttpURLConnection con = (HttpURLConnection)url.openConnection();
   110                 HttpURLConnection con = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
   109                 con.setDoOutput(true);
   111                 con.setDoOutput(true);
   110                 con.setDoInput(true);
   112                 con.setDoInput(true);
   111                 con.setRequestMethod("POST");
   113                 con.setRequestMethod("POST");
   112                 con.setRequestProperty(
   114                 con.setRequestProperty(
   113                     "Content-Type",
   115                     "Content-Type",
   146     }
   148     }
   147 
   149 
   148 
   150 
   149     private static HttpServer createHttpServer(ExecutorService execs)
   151     private static HttpServer createHttpServer(ExecutorService execs)
   150         throws Exception {
   152         throws Exception {
   151         InetSocketAddress inetAddress = new InetSocketAddress(0);
   153         InetAddress loopback = InetAddress.getLoopbackAddress();
       
   154         InetSocketAddress inetAddress = new InetSocketAddress(loopback, 0);
   152         HttpServer testServer = HttpServer.create(inetAddress, 15);
   155         HttpServer testServer = HttpServer.create(inetAddress, 15);
   153         testServer.setExecutor(execs);
   156         testServer.setExecutor(execs);
   154         HttpContext context = testServer.createContext("/test");
   157         HttpContext context = testServer.createContext("/test");
   155         context.setHandler(new HttpHandler() {
   158         context.setHandler(new HttpHandler() {
   156             public void handle(HttpExchange msg) {
   159             public void handle(HttpExchange msg) {