equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2010, 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. |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @bug 4361492 |
26 * @bug 4361492 |
27 * @summary HTTPUrlConnection does not receive binary data correctly |
27 * @summary HTTPUrlConnection does not receive binary data correctly |
|
28 * @library /test/lib |
28 * @run main/timeout=20 ResendPostBody |
29 * @run main/timeout=20 ResendPostBody |
29 */ |
30 */ |
30 |
31 |
31 import java.io.*; |
32 import java.io.*; |
32 import java.net.*; |
33 import java.net.*; |
|
34 |
|
35 import jdk.test.lib.net.URIBuilder; |
33 |
36 |
34 /* |
37 /* |
35 * This test does the following: |
38 * This test does the following: |
36 * 1. client opens HTTP connection to server |
39 * 1. client opens HTTP connection to server |
37 * 2. client sends POST with a body containing "ZZZ" |
40 * 2. client sends POST with a body containing "ZZZ" |
137 |
140 |
138 public void execute () throws Exception { |
141 public void execute () throws Exception { |
139 |
142 |
140 byte b[] = "X=ABCDEFGHZZZ".getBytes(); |
143 byte b[] = "X=ABCDEFGHZZZ".getBytes(); |
141 |
144 |
142 ss = new ServerSocket (0); |
145 ss = new ServerSocket(0, 0, InetAddress.getLoopbackAddress()); |
143 server = new Server (ss); |
146 server = new Server (ss); |
144 server.start (); |
147 server.start (); |
145 /* Get the URL */ |
148 /* Get the URL */ |
146 |
149 URL url = URIBuilder.newBuilder() |
147 String s = "http://localhost:"+ss.getLocalPort()+"/test"; |
150 .scheme("http") |
148 URL url = new URL(s); |
151 .loopback() |
|
152 .port(ss.getLocalPort()) |
|
153 .path("/test") |
|
154 .toURL(); |
149 HttpURLConnection conURL = (HttpURLConnection)url.openConnection(); |
155 HttpURLConnection conURL = (HttpURLConnection)url.openConnection(); |
150 |
156 |
151 conURL.setDoOutput(true); |
157 conURL.setDoOutput(true); |
152 conURL.setDoInput(true); |
158 conURL.setDoInput(true); |
153 conURL.setAllowUserInteraction(false); |
159 conURL.setAllowUserInteraction(false); |