6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6726695
27 * @summary HttpURLConnection shoul support 'Expect: 100-contimue' headers for PUT
28 */
29
30 import java.net.*;
31 import java.io.*;
32
33 public class B6726695 extends Thread {
34 private ServerSocket server = null;
35 private int port = 0;
36 private byte[] data = new byte[512];
37 private String boundary = "----------------7774563516523621";
38
39 public static void main(String[] args) throws Exception {
40 B6726695 test = new B6726695();
41 // Exit even if server is still running
42 test.setDaemon(true);
43 // start server
44 test.start();
45 // run test
46 test.test();
167 out.print("\r\n");
168 out.flush();
169 out.close();
170 in.close();
171 }
172
173 public void serverAccept(Socket s) throws IOException {
174 BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
175 PrintStream out = new PrintStream(new BufferedOutputStream(s.getOutputStream()));
176 String line = null;
177 do {
178 line = in.readLine();
179 } while (line != null && line.length() != 0);
180
181 // Send 100-Continue
182 out.print("HTTP/1.1 100 Continue\r\n");
183 out.print("\r\n");
184 out.flush();
185 // Then read the body
186 char[] cbuf = new char[512];
187 int l = in.read(cbuf);
188 // finally send the 200 OK
189 out.print("HTTP/1.1 200 OK");
190 out.print("Server: Sun-Java-System-Web-Server/7.0\r\n");
191 out.print("Connection: close\r\n");
192 out.print("Content-Length: 0\r\n");
193 out.print("\r\n");
194 out.flush();
195 out.close();
196 in.close();
197 }
198
199 public void serverIgnore(Socket s) throws IOException {
200 BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
201 PrintStream out = new PrintStream(new BufferedOutputStream(s.getOutputStream()));
202 String line = null;
203 do {
204 line = in.readLine();
205 } while (line != null && line.length() != 0);
206
207 // Then read the body
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6726695 6993490
27 * @summary HttpURLConnection shoul support 'Expect: 100-contimue' headers for PUT
28 */
29
30 import java.net.*;
31 import java.io.*;
32
33 public class B6726695 extends Thread {
34 private ServerSocket server = null;
35 private int port = 0;
36 private byte[] data = new byte[512];
37 private String boundary = "----------------7774563516523621";
38
39 public static void main(String[] args) throws Exception {
40 B6726695 test = new B6726695();
41 // Exit even if server is still running
42 test.setDaemon(true);
43 // start server
44 test.start();
45 // run test
46 test.test();
167 out.print("\r\n");
168 out.flush();
169 out.close();
170 in.close();
171 }
172
173 public void serverAccept(Socket s) throws IOException {
174 BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
175 PrintStream out = new PrintStream(new BufferedOutputStream(s.getOutputStream()));
176 String line = null;
177 do {
178 line = in.readLine();
179 } while (line != null && line.length() != 0);
180
181 // Send 100-Continue
182 out.print("HTTP/1.1 100 Continue\r\n");
183 out.print("\r\n");
184 out.flush();
185 // Then read the body
186 char[] cbuf = new char[512];
187 in.read(cbuf);
188
189 /* Force the server to not respond for more that the expect 100-Continue
190 * timeout set by the HTTP handler (5000 millis). This ensures the
191 * timeout is correctly resets the default read timeout, infinity.
192 * See 6993490. */
193 System.out.println("server sleeping...");
194 try {Thread.sleep(6000); } catch (InterruptedException e) {}
195
196 // finally send the 200 OK
197 out.print("HTTP/1.1 200 OK");
198 out.print("Server: Sun-Java-System-Web-Server/7.0\r\n");
199 out.print("Connection: close\r\n");
200 out.print("Content-Length: 0\r\n");
201 out.print("\r\n");
202 out.flush();
203 out.close();
204 in.close();
205 }
206
207 public void serverIgnore(Socket s) throws IOException {
208 BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
209 PrintStream out = new PrintStream(new BufferedOutputStream(s.getOutputStream()));
210 String line = null;
211 do {
212 line = in.readLine();
213 } while (line != null && line.length() != 0);
214
215 // Then read the body
|