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

HttpUrlConnection Set-Cookie Header lost with WebStart

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • tbd
    • 7u67, 8, 9
    • deploy

      FULL PRODUCT VERSION :
      java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode)
      Netbeans 7.1.2

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

      A DESCRIPTION OF THE PROBLEM :
      When I request any website with HttpUrlConnection, which sends an "Set-Cookie" header, this header is not retuned with
      HttpUrlConnection.getHeaderFields(). This happens ony if I run the program as signed WebStart Application. When I start the program 'normal' all header fields are retuned as expected.

      It has worked with JDK 6.X.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached code as signed WebStart Application under Java 7.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Excecuted as normal Application:
      null [HTTP/1.1 200 OK]
      X-Frame-Options [SAMEORIGIN]
      Transfer-Encoding [chunked]
      Date [Tue, 26 Jun 2012 09:59:35 GMT]
      P3P [CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."]
      X-XSS-Protection [1; mode=block]
      Expires [-1]
      Set-Cookie [NID=61=ecJkGVIQMaJpax; expires=Wed, 26-Dec-2012 09:59:35 GMT; path=/; domain=.google.de; HttpOnly, PREF=ID=f51c6bed932ab134:FF=0:TM=1340704775:LM=1340704775:S=lu5r5YK94s5TBFGl; expires=Thu, 26-Jun-2014 09:59:35 GMT; path=/; domain=.google.de, NID=61=ecJkGVIQMaJpax3svYNOQpkv_--01nkmmgzR3gKIRqrKTOYznWG2SJPTlmNra-dNrvd-ppN5gSnK55kKFFLdbR84PHwAFB2B_8qlePTbmkvuNP7rxdxbmkq7walVhgry; expires=Wed, 26-Dec-2012 09:59:35 GMT; path=/; domain=.google.de; HttpOnly]
      Content-Type [text/html; charset=ISO-8859-1]
      Server [gws]
      Cache-Control [private, max-age=0]
      ACTUAL -
      Excecuted as WebStart Application (The line with Set-Cookie.. is missing):

      null [HTTP/1.1 200 OK]
      X-Frame-Options [SAMEORIGIN]
      Transfer-Encoding [chunked]
      Date [Tue, 26 Jun 2012 10:03:10 GMT]
      P3P [CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."]
      X-XSS-Protection [1; mode=block]
      Expires [-1]
      Content-Type [text/html; charset=ISO-8859-1]
      Server [gws]
      Cache-Control [private, max-age=0]


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) {
              try {
                  URL url = new URL("http://www.google.de"); //Any Http Server that sends a Set-Cookie Header
                  HttpURLConnection openConnection = (HttpURLConnection)url.openConnection();

                  Map<String, List<String>> headerFields = openConnection.getHeaderFields();
                  Set<Entry<String, List<String>>> entrySet = headerFields.entrySet();
                  for (Entry<String, List<String>> e : entrySet) {
                      System.out.printf("%s %s\r\n", e.getKey(), e.getValue());
                  }
                  String headerField = openConnection.getHeaderField("Set-Cookie"); //With WebStart headerField is null
              } catch (Exception ex) {
                  System.out.println(ex.getMessage());
              }
          }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      When I set the default CookieHandler to null the Set-Cookie header is returned even in WebStart mode.

      CookieHandler.setDefault(null);

            dtitov Daniil Titov (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: