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

The java.net.URLConnection.setDoOutput(true) does not set DoInput to false

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      merlin
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.5, windows_95

      Description



      Name: yyC67448 Date: 02/19/98



      The java.net.URLConnection.setDoOutput(boolean dooutput) does not alter the
      doInput value. So when doOutput is explicitly set to true the default value
      for doInput remain true.

      Here is the javadoc comment for method setDoInput


          /**
           * Sets the value of the <code>doInput</code> field for this
           * <code>URLConnection</code> to the specified value.
           * <p>
           * A URL connection can be used for input and/or output. Set the DoInput
           * flag to true if you intend to use the URL connection for input,
           * false if not. The default is true unless DoOutput is explicitly
           * set to true, in which case DoInput defaults to false.
           *
           * @param value the new value.
           * @see java.net.URLConnection#doInput
           * @since JDK1.0
           */



      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 spec="http://web2.javasoft.com/index.html";
         
         
         try {
           url = new URL(spec);
           conn = url.openConnection();
         } catch(Exception e)
         {
           System.out.println("Failed. Unexpected exception:" + e);
           System.exit(-1);
         }
         
         /*
          * Setting doOutput value to true
          */
         conn.setDoOutput(true);
         
         /*
          * Verify, that doOutput is really true
          */
         if( conn.getDoOutput() != true )
         {
          System.out.println("Failed. doOutput isn't set to true");
          System.exit(-1);
         }
         
         /*
          * Now verify the doInput value
          */
          if( conn.getDoInput() != false )
          {
           System.out.println("Failed. doInput is true.");
           System.exit(-1);
          }
          
          System.out.println("Passed. OKAY");


        }
         
      }
      ------------------------- Output from the test ----------------------------
      Failed. doInput is true.
      ---------------------------------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            michaelm Michael McMahon
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: