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

Reviewed-by: dfuchs
This commit is contained in:
Evan Whelan 2021-09-09 10:23:12 +00:00 committed by Daniel Fuchs
parent aa9311182a
commit 00e059ddb3
7 changed files with 388 additions and 46 deletions

View file

@ -589,6 +589,14 @@ public abstract class URLConnection {
* unmodifiable List of Strings that represents
* the corresponding field values.
*
* This method is overridden by the subclasses of {@code URLConnection}.
*
* In the implementation of these methods, if a given key has multiple
* corresponding values, they must be returned in the order they were added,
* preserving the insertion-order.
*
* @implSpec The default implementation of this method returns an empty map always.
*
* @return a Map of header fields
* @since 1.4
*/
@ -1134,6 +1142,10 @@ public abstract class URLConnection {
* key-value pair. This method will not overwrite
* existing values associated with the same key.
*
* This method could be a no-op if appending a value
* to the map is not supported by the protocol being
* used in a given subclass.
*
* @param key the keyword by which the request is known
* (e.g., "{@code Accept}").
* @param value the value associated with it.
@ -1181,6 +1193,16 @@ public abstract class URLConnection {
* of Strings that represents the corresponding
* field values.
*
* If multiple values for a given key are added via the
* {@link #addRequestProperty(String, String)} method,
* these values will be returned in the order they were
* added. This method must preserve the insertion order
* of such values.
*
* 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
* @since 1.4