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

Doc for java.net.setDefaultRequestProperty() need to be updated

XMLWordPrintable

    • b28
    • generic, sparc
    • generic, solaris_2.5
    • Verified

      Name: dfC67450 Date: 08/17/99



      Javadoc says about java.net.setDefaultRequestProperty(String key, String value)
      and java.net.getDefaultRequestProperty():

          /**
           * Sets the default value of a general request property. When a
           * <code>URLConnection</code> is created, it is initialized with
           * these properties.
           *
           * @param key the keyword by which the request is known
           * (e.g., "<code>accept</code>").
           * @param value the value associated with the key.
           *
           * @see java.net.URLConnection#setRequestProperty(java.lang.String,java.lang.String)
           *
           * @deprecated The instance specific setRequestProperty method
           * should be used after an appropriate instance of URLConnection
           * is obtained.
           */



          /**
           * Returns the value of the default request property. Default request
           * properties are set for every connection.
           *
           * @param key the keyword by which the request is known (e.g., "accept").
           * @return the value of the default request property
           * for the specified key.
           *
           * @see java.net.URLConnection#getRequestProperty(java.lang.String)
           *
           * @deprecated The instance specific getRequestProperty method
           * should be used after an appropriate instance of URLConnection
           * is obtained.
           */

      It should note that setDefaultRequestProperty method can not set property.

      Here is the test demonstrating the bug:

      ------------------------ Test.java ---------------------------------------
      import java.net.*;

      public class Test {

          public static void main(String args[]) {

              URL url = null;
              URLConnection conn = null;
              String key = "accept-charset";
              String value = "iso-8859-5";
         
         
              URLConnection.setDefaultRequestProperty(key, value);

              if( !value.equals(URLConnection.getDefaultRequestProperty(key) )) {
                  System.out.println("Failed. Default Property is not set.");
              } else {
                  System.out.println("Passed. OKAY");
              }
          }
      }

      ------------------------- Output from the test ----------------------------
      Failed. Default Property is not set.
      ---------------------------------------------------------------------------


      ======================================================================

            shommel Scott Hommel (Inactive)
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: