test/jdk/sun/net/www/protocol/http/SetChunkedStreamingMode.java
changeset 54314 46cf212cdcca
parent 47216 71c04702a3d5
child 55045 3a8433d967ea
equal deleted inserted replaced
54313:440cbcf3b268 54314:46cf212cdcca
    24 /**
    24 /**
    25  * @test
    25  * @test
    26  * @bug 5049976
    26  * @bug 5049976
    27  * @modules java.base/sun.net.www
    27  * @modules java.base/sun.net.www
    28  * @library ../../httptest/
    28  * @library ../../httptest/
       
    29  * @library /test/lib
    29  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
    30  * @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
    30  * @run main SetChunkedStreamingMode
    31  * @run main SetChunkedStreamingMode
    31  * @summary Unspecified NPE is thrown when streaming output mode is enabled
    32  * @summary Unspecified NPE is thrown when streaming output mode is enabled
    32  */
    33  */
    33 
    34 
    34 import java.io.*;
    35 import java.io.*;
    35 import java.net.*;
    36 import java.net.*;
       
    37 import jdk.test.lib.net.URIBuilder;
    36 
    38 
    37 public class SetChunkedStreamingMode implements HttpCallback {
    39 public class SetChunkedStreamingMode implements HttpCallback {
    38 
    40 
    39     void okReply (HttpTransaction req) throws IOException {
    41     void okReply (HttpTransaction req) throws IOException {
    40         req.setResponseEntityBody ("Hello .");
    42         req.setResponseEntityBody ("Hello .");
    65 
    67 
    66     public static void main (String[] args) throws Exception {
    68     public static void main (String[] args) throws Exception {
    67         try {
    69         try {
    68             server = new TestHttpServer (new SetChunkedStreamingMode(), 1, 10, 0);
    70             server = new TestHttpServer (new SetChunkedStreamingMode(), 1, 10, 0);
    69             System.out.println ("Server: listening on port: " + server.getLocalPort());
    71             System.out.println ("Server: listening on port: " + server.getLocalPort());
    70             URL url = new URL ("http://127.0.0.1:"+server.getLocalPort()+"/");
    72             URL url = URIBuilder.newBuilder()
       
    73                 .scheme("http")
       
    74                 .loopback()
       
    75                 .port(server.getLocalPort())
       
    76                 .path("/")
       
    77                 .toURL();
    71             System.out.println ("Client: connecting to " + url);
    78             System.out.println ("Client: connecting to " + url);
    72             HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
    79             HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
    73             urlc.setChunkedStreamingMode (0);
    80             urlc.setChunkedStreamingMode (0);
    74             urlc.setRequestMethod("POST");
    81             urlc.setRequestMethod("POST");
    75             urlc.setDoOutput(true);
    82             urlc.setDoOutput(true);