Skip to content

Commit

Permalink
8163921: HttpURLConnection default Accept header is malformed accordi…
Browse files Browse the repository at this point in the history
…ng to HTTP/1.1 RFC

Reviewed-by: dfuchs, michaelm
  • Loading branch information
djelinski authored and Michael-Mc-Mahon committed Jan 25, 2022
1 parent c43ce85 commit 28796cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -288,8 +288,7 @@ private static Set<String> schemesListToSet(String list) {
}

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.
Expand Down
16 changes: 8 additions & 8 deletions test/jdk/sun/net/www/B8185898.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,7 +23,7 @@

/**
* @test
* @bug 8185898
* @bug 8185898 8163921
* @modules java.base/sun.net.www
* @library /test/lib
* @run main/othervm B8185898
Expand Down Expand Up @@ -143,32 +143,32 @@ static void testMessageHeaderMethods() throws IOException {
// {{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"
Expand Down

3 comments on commit 28796cb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 28796cb Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 28796cb Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-28796cbd in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 28796cbd from the openjdk/jdk repository.

The commit being backported was authored by Daniel Jeliński on 25 Jan 2022 and was reviewed by Daniel Fuchs and Michael McMahon.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-28796cbd:backport-GoeLin-28796cbd
$ git checkout backport-GoeLin-28796cbd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-28796cbd

Please sign in to comment.