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

'Authorization' header not header initially not sent via HttpUrlConnection

XMLWordPrintable

      FULL PRODUCT VERSION :
      Java Web Start 10.25.2.17
      Using JRE version 1.7.0_25-b17 Java HotSpot(TM) Client VM

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Initially setting the 'Authorization' header pre-emptively on a 'java.net.HttpURLConnection' is not passed to the endpoint which results in a HTTP/401 error however subsequent setting of this header works successfully.

      This only appear to be a problem with WebStart and connecting to a HTTPS connection as the actual instance is a 'sun.net.www.protocol.https.HttpsURLConnectionImpl'. I believe this is due to caching of headers within WebStart however I cannot confirm this.



      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Launch via WebStart
      2. Open a connection to an endpoint that expects an 'Authorization' header using java.net.URL#openConnection(),
      3. Set java.net.URLConnection#addRequestProperty("Authorization", ... some auth key...),
      4. Open connection using java.net.URLConnection#getInputStream()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Endpoint receives the 'Authorization' header
      ACTUAL -
      On initial connection the endpoint does not receive the header, subsequent connections do.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      HTTP/401 Not Authorised

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      I'm unable to supply code due to the restrictions from my client.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      java.net.URLConnection.setUseCaches(false)

            dcherepanov Dmitry Cherepanov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: