mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8163921: HttpURLConnection default Accept header is malformed according to HTTP/1.1 RFC
Reviewed-by: dfuchs, michaelm
This commit is contained in:
parent
c43ce85f01
commit
28796cbd1d
2 changed files with 10 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -288,8 +288,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||
}
|
||||
|
||||
static final String httpVersion = "HTTP/1.1";
|
||||
static final String acceptString =
|
||||
"text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
|
||||
static final String acceptString = "*/*";
|
||||
|
||||
// the following http request headers should NOT have their values
|
||||
// returned for security reasons.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8185898
|
||||
* @bug 8185898 8163921
|
||||
* @modules java.base/sun.net.www
|
||||
* @library /test/lib
|
||||
* @run main/othervm B8185898
|
||||
|
@ -143,32 +143,32 @@ public class B8185898 {
|
|||
// {{inputString1, expectedToString1, expectedPrint1}, {...}}
|
||||
String[][] strings = {
|
||||
{"HTTP/1.1 200 OK\r\n"
|
||||
+ "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n"
|
||||
+ "Accept: */*\r\n"
|
||||
+ "Connection: keep-alive\r\n"
|
||||
+ "Host: 127.0.0.1:12345\r\n"
|
||||
+ "User-agent: Java/12\r\n\r\nfoooo",
|
||||
"pairs: {null: HTTP/1.1 200 OK}"
|
||||
+ "{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}"
|
||||
+ "{Accept: */*}"
|
||||
+ "{Connection: keep-alive}"
|
||||
+ "{Host: 127.0.0.1:12345}"
|
||||
+ "{User-agent: Java/12}",
|
||||
"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n"
|
||||
"Accept: */*\r\n"
|
||||
+ "Connection: keep-alive\r\n"
|
||||
+ "Host: 127.0.0.1:12345\r\n"
|
||||
+ "User-agent: Java/12\r\n\r\n"},
|
||||
{"HTTP/1.1 200 OK\r\n"
|
||||
+ "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n"
|
||||
+ "Accept: */*\r\n"
|
||||
+ "Connection: keep-alive\r\n"
|
||||
+ "Host: 127.0.0.1:12345\r\n"
|
||||
+ "User-agent: Java/12\r\n"
|
||||
+ "X-Header:\r\n\r\n",
|
||||
"pairs: {null: HTTP/1.1 200 OK}"
|
||||
+ "{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}"
|
||||
+ "{Accept: */*}"
|
||||
+ "{Connection: keep-alive}"
|
||||
+ "{Host: 127.0.0.1:12345}"
|
||||
+ "{User-agent: Java/12}"
|
||||
+ "{X-Header: }",
|
||||
"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n"
|
||||
"Accept: */*\r\n"
|
||||
+ "Connection: keep-alive\r\n"
|
||||
+ "Host: 127.0.0.1:12345\r\n"
|
||||
+ "User-agent: Java/12\r\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue