Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6390747

doc: java.net.URLConnection.getRequestProperty()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6
    • core-libs
    • generic
    • generic

      The spec for method getRequestProperty(String key) does not clearly define which property should be returned if request contains more then one values with the same key. Example:

      import java.net.*;

      public class RequestPropertyTest {
      static public void main(String args[]) throws Exception {
          URLConnection c = new URL("http:/www.sun.com").openConnection();
          c.addRequestProperty("key", "valueOne");
          c.addRequestProperty("key", "valueTwo");
          System.out.println(c.getRequestProperty("key"));
      }
      }
      This test prints 'valueTwo' now.

      But the spec says nothing about what value should be returned. It means that different Java implementations can work differently.

      The description of this method should be clarified.
      Possibly it makes sense to add explicit note that multiple values can be associated with one key and add 'see also' reference to the 'Map<String,List<String>> getRequestProperties()' method into the description.

      Also there is another problem: the description of 'addRequestProperty' has more than one meaning:
      - new value added to the values list (current meaning)
      - value is not added if there is a value for the given key

            Unassigned Unassigned
            itseytin Igor Tseytin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: