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

HttpURLConnection sets Content-Type to application/x-www-form-urlencoded

XMLWordPrintable

    • b71
    • x86
    • windows_xp

        FULL PRODUCT VERSION :
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
        Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Windows XP Professional Version 2002 Service Pack 2
        Linux jclinux 2.4.21-32.0.1.EL #1 Tue May 17 18:01:37 EDT 2005 i686 i686 i386 GNU/Linux


        A DESCRIPTION OF THE PROBLEM :
        In Java 5.0, HttpURLConnection, by defaults, sets Content-Type to application/x-www-form-urlencoded

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run code like this on JDK1.4.X and on JDK1.5 and see the value of the content-type header:

                URL url = new URL(argv[0]);

                HttpURLConnection connect = (HttpURLConnection) url.openConnection();
                connect.setRequestMethod("GET");
                connect.setDoInput(true);
                connect.setDoOutput(false);
                InputStream in;
                in = connect.getInputStream();

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        I was expecting no content-type header
        ACTUAL -
        The request had a content-type header set to application/x-www-form-urlencoded

        REPRODUCIBILITY :
        This bug can be reproduced always.

              chegar Chris Hegarty
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: