Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8133686: HttpURLConnection.getHeaderFields and URLConnection.getRequestProperties methods return field values in reverse order #2294

Closed
wants to merge 6 commits into from
8 changes: 5 additions & 3 deletions src/java.base/share/classes/java/net/URLConnection.java
Original file line number Diff line number Diff line change
@@ -594,6 +594,8 @@ public String getHeaderField(String name) {
* corresponding values, they must be returned in the order they were added,
* preserving the insertion-order.
*
* @implNote The default implementation of this method returns an empty map always.
*
* @return a Map of header fields
* @since 1.4
*/
@@ -1196,9 +1198,9 @@ public String getRequestProperty(String key) {
* added. This method must preserve the insertion order
* of such values.
*
Copy link
Member

Choose a reason for hiding this comment

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

But we have made addRequestProperty effectively a no-op ( as above ) !

Copy link
Member

Choose a reason for hiding this comment

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

We are allowing it to be a no-op. But if it's not a no-op then it must return values in the order they were added. The other option is to make the order non normative and protocol dependent (and possibly move the normative text to the HttpURLConnection/HttpsURLConnection/JarURLConnection.

* @implSpec The default implementation of this method should preserve insertion order when
* multiple values are added for a given key. They must be
* returned in the order they were added.
* @implNote The default implementation of this method preserves the insertion order when
* multiple values are added for a given key. The values are returned in the order they
* were added.
*
* @return a Map of the general request properties for this connection.
* @throws IllegalStateException if already connected