Skip to content

Commit 827528c

Browse files
Dan LutkerVictor Rudometov
authored andcommitted
8339470: [17u] More defensive fix for 8163921
Backport-of: 6261dd7
1 parent 96805ae commit 827528c

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -300,7 +300,8 @@ private static Set<String> schemesListToSet(String list) {
300300
}
301301

302302
static final String httpVersion = "HTTP/1.1";
303-
static final String acceptString = "*/*";
303+
static final String acceptString =
304+
"text/html, image/gif, image/jpeg, */*; q=0.2";
304305

305306
// the following http request headers should NOT have their values
306307
// returned for security reasons.

test/jdk/sun/net/www/B8185898.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* @test
26-
* @bug 8185898 8163921
26+
* @bug 8185898 8163921 8339470
2727
* @modules java.base/sun.net.www
2828
* @library /test/lib
2929
* @run main/othervm B8185898
@@ -143,32 +143,32 @@ static void testMessageHeaderMethods() throws IOException {
143143
// {{inputString1, expectedToString1, expectedPrint1}, {...}}
144144
String[][] strings = {
145145
{"HTTP/1.1 200 OK\r\n"
146-
+ "Accept: */*\r\n"
146+
+ "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n"
147147
+ "Connection: keep-alive\r\n"
148148
+ "Host: 127.0.0.1:12345\r\n"
149149
+ "User-agent: Java/12\r\n\r\nfoooo",
150150
"pairs: {null: HTTP/1.1 200 OK}"
151-
+ "{Accept: */*}"
151+
+ "{Accept: text/html, image/gif, image/jpeg, */*; q=0.2}"
152152
+ "{Connection: keep-alive}"
153153
+ "{Host: 127.0.0.1:12345}"
154154
+ "{User-agent: Java/12}",
155-
"Accept: */*\r\n"
155+
"Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n"
156156
+ "Connection: keep-alive\r\n"
157157
+ "Host: 127.0.0.1:12345\r\n"
158158
+ "User-agent: Java/12\r\n\r\n"},
159159
{"HTTP/1.1 200 OK\r\n"
160-
+ "Accept: */*\r\n"
160+
+ "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n"
161161
+ "Connection: keep-alive\r\n"
162162
+ "Host: 127.0.0.1:12345\r\n"
163163
+ "User-agent: Java/12\r\n"
164164
+ "X-Header:\r\n\r\n",
165165
"pairs: {null: HTTP/1.1 200 OK}"
166-
+ "{Accept: */*}"
166+
+ "{Accept: text/html, image/gif, image/jpeg, */*; q=0.2}"
167167
+ "{Connection: keep-alive}"
168168
+ "{Host: 127.0.0.1:12345}"
169169
+ "{User-agent: Java/12}"
170170
+ "{X-Header: }",
171-
"Accept: */*\r\n"
171+
"Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n"
172172
+ "Connection: keep-alive\r\n"
173173
+ "Host: 127.0.0.1:12345\r\n"
174174
+ "User-agent: Java/12\r\n"

0 commit comments

Comments
 (0)