RFR: JDK-8268464 : Remove dependancy of TestHttpsServer, HttpTransaction, HttpCallback from open/test/jdk/sun/net/www/protocol/https/ tests
Daniel Fuchs
dfuchs at openjdk.java.net
Wed Jun 9 15:40:15 UTC 2021
On Wed, 9 Jun 2021 14:42:23 GMT, Mahendra Chhipa <github.com+34924738+mahendrachhipa at openjdk.org> wrote:
> …HttpCallback from open/test/jdk/sun/net/www/protocol/https/ tests
test/jdk/sun/net/www/protocol/https/ChunkedOutputStream.java line 116:
> 114: String reqbody = "";
> 115: try(InputStream inputStream = req.getRequestBody()) {
> 116: if(inputStream != null) {
I don't think inputStream can be null, ever.
test/jdk/sun/net/www/protocol/https/ChunkedOutputStream.java line 117:
> 115: try(InputStream inputStream = req.getRequestBody()) {
> 116: if(inputStream != null) {
> 117: reqbody = new String(inputStream.readAllBytes());
Please double check that client and server use the same charset.
test/jdk/sun/net/www/protocol/https/ChunkedOutputStream.java line 138:
> 136: break;
> 137: case 2: /* test 3 */
> 138: reqbody = new String(req.getRequestBody().readAllBytes());
Please double check that client and server use the same charset.
test/jdk/sun/net/www/protocol/https/ChunkedOutputStream.java line 150:
> 148: req.getResponseHeaders().set("Connection", "close");
> 149: req.sendResponseHeaders(200, 0);
> 150: try (PrintWriter pw = new PrintWriter(req.getResponseBody())) {
It's dangerous to rely on the default charset when using PrintWriter.
I'd suggest to change the client and server logic to use UTF-8 explicitly everywhere (when creating new strings, when obtaining string bytes, when using print writers or print streams, etc...)
test/jdk/sun/net/www/protocol/https/ChunkedOutputStream.java line 161:
> 159: case 4: /* test 7 */
> 160: case 5: /* test 8 */
> 161: reqbody = new String(req.getRequestBody().readAllBytes());
Please double check that client and server use the same charset, or better, explicitly use UTF-8 everywhere.
test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java line 218:
> 216: // if the bug exsits, it'll send 2 GET commands
> 217: // check 2nd GET here
> 218: String duplicatedGet = trans.getRequestHeaders().getFirst(null);
I'm not sure you will be testing the same thing here. You probably can't use the com.sun.net.httpserver.HttpServer for this.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4432
More information about the security-dev
mailing list