equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2018, 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. |
29 * jdk.httpserver |
29 * jdk.httpserver |
30 * @library /lib/testlibrary/ /test/lib |
30 * @library /lib/testlibrary/ /test/lib |
31 * @compile ../../../com/sun/net/httpserver/LogFilter.java |
31 * @compile ../../../com/sun/net/httpserver/LogFilter.java |
32 * @compile ../../../com/sun/net/httpserver/EchoHandler.java |
32 * @compile ../../../com/sun/net/httpserver/EchoHandler.java |
33 * @compile ../../../com/sun/net/httpserver/FileServerHandler.java |
33 * @compile ../../../com/sun/net/httpserver/FileServerHandler.java |
|
34 * @build jdk.testlibrary.SimpleSSLContext |
|
35 * @build LightWeightHttpServer |
34 * @build jdk.test.lib.Platform |
36 * @build jdk.test.lib.Platform |
35 * @build jdk.test.lib.util.FileUtils |
37 * @build jdk.test.lib.util.FileUtils |
36 * @build LightWeightHttpServer |
|
37 * @build jdk.testlibrary.SimpleSSLContext |
|
38 * @run testng/othervm RequestBodyTest |
38 * @run testng/othervm RequestBodyTest |
|
39 * @run testng/othervm/java.security.policy=RequestBodyTest.policy RequestBodyTest |
39 */ |
40 */ |
40 |
41 |
41 import java.io.*; |
42 import java.io.*; |
42 import java.net.URI; |
43 import java.net.URI; |
43 import java.net.http.HttpClient; |
44 import java.net.http.HttpClient; |
49 import java.nio.charset.Charset; |
50 import java.nio.charset.Charset; |
50 import java.nio.charset.StandardCharsets; |
51 import java.nio.charset.StandardCharsets; |
51 import java.nio.file.Files; |
52 import java.nio.file.Files; |
52 import java.nio.file.Path; |
53 import java.nio.file.Path; |
53 import java.nio.file.Paths; |
54 import java.nio.file.Paths; |
|
55 import java.security.AccessController; |
|
56 import java.security.PrivilegedActionException; |
|
57 import java.security.PrivilegedExceptionAction; |
54 import java.util.ArrayList; |
58 import java.util.ArrayList; |
55 import java.util.Arrays; |
59 import java.util.Arrays; |
56 import java.util.List; |
60 import java.util.List; |
57 import java.util.Optional; |
61 import java.util.Optional; |
58 import java.util.concurrent.ConcurrentHashMap; |
62 import java.util.concurrent.ConcurrentHashMap; |
326 return new Supplier<>() { |
330 return new Supplier<>() { |
327 Path file = f; |
331 Path file = f; |
328 @Override |
332 @Override |
329 public FileInputStream get() { |
333 public FileInputStream get() { |
330 try { |
334 try { |
331 return new FileInputStream(file.toFile()); |
335 PrivilegedExceptionAction<FileInputStream> pa = |
332 } catch (FileNotFoundException x) { |
336 () -> new FileInputStream(file.toFile()); |
333 throw new UncheckedIOException(x); |
337 return AccessController.doPrivileged(pa); |
|
338 } catch (PrivilegedActionException x) { |
|
339 throw new UncheckedIOException((IOException)x.getCause()); |
334 } |
340 } |
335 } |
341 } |
336 }; |
342 }; |
337 } |
343 } |
338 |
344 |