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

Java Plugin ignores cookies on outgoing requests.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.3.0_01
    • deploy
    • None
    • beta2
    • x86
    • generic

      Stanley, I'm 100% sure this is either a bug in the java plugin/JDK, or there is some simple user error thing.

      This is from bugzilla bug: http://bugzilla.mozilla.org/show_bug.cgi?id=79851

      The problem is that the plugin forgets any Cookies sent from the server. I'm about to attach an applet that causes two complete HTTP request/response transactions to occurr. The first is a GET, the second is a POST. The respons from the GET request contains a Set-Cookie header, but the request of the POST does not contain this Set-Cookie header, thus any session information is lost.

      Here's how I know what's going on.

      I've modified my D:\Projects\ladybird\src\share\classes\sun\net\www\http\HttpClient.java like this:

      --- HttpClient.java Tue May 15 12:29:02 2001
      +++ HttpClient.java~ Mon Nov 13 19:39:11 2000
      @@ -577,9 +577,6 @@
       
           public void writeRequests(MessageHeader head) {
        requests = head;
      - System.out.println("debug: edburns: HttpClient.writeRequests:\n\t" +
      - requests.toString());
      -
        requests.print(serverOutput);
        serverOutput.flush();
           }
      @@ -628,6 +625,7 @@
        * and instead just queue up the output stream to it's very beginning.
        * This seems most reasonable, and is what the NN browser does.
        */
      +
        keepAliveConnections = -1;
        keepAliveTimeout = 0;
       
      @@ -650,8 +648,6 @@
        ((PushbackInputStream) serverInput).unread(b);
        if (ret) { // is valid HTTP - response started w/ "HTTP/1."
        responses.parseHeader(serverInput);
      - System.out.println("debug: edburns: HttpClient.parseHTTPHeader:\n\t" +
      - responses.toString());
        /* decide if we're keeping alive:
        * This is a bit tricky. There's a spec, but most current
        * servers (10/1/96) that support this differ in dialects.

      Then executed the attached applet/servlet pair, and I see this output on the java console:

      Trace level set to 2: basic, net ... completed.
      Registered modality listener
      Referencing classloader: sun.plugin.ClassLoaderInfo@6cb281, refcount=1
      Added trace listener: sun.plugin.navig.win32.AppletPluginPanel[mozilla_session_bug.UntitledApplet,0,0,400x400,invalid,layout=java.awt.BorderLayout]
      Sending events to applet. LOAD
      Sending events to applet. INIT
      Sending events to applet. START
      Determine if the applet requests to install any HTML page
      HTML Installation finished.
      Determine if the applet requests to install any JAR
      Jar cache option: null
      Jar archive(s): null
      Jar cache version(s): null
      Applet Installation finished.
      Started ...
      Opening http://127.0.0.1:8080/servlet/Untitled1
      Connecting http://127.0.0.1:8080/servlet/Untitled1 with proxy=arago.eng.sun.com:8070
      debug: edburns: HttpClient.writeRequests:
      www.MessageHeader@439a20'>sun.net.www.MessageHeader@439a20
      {GET /servlet/Untitled1 HTTP/1.1: null}
      {User-Agent: Java1.3.1-rc1}
      {Host: 127.0.0.1:8080}
      {Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}
      {Connection: keep-alive}
      {null: null}
      {null: null}
      {null: null}
      debug: edburns: HttpClient.parseHTTPHeader:
      www.MessageHeader@6df0f'>sun.net.www.MessageHeader@6df0f
      {null: HTTP/1.1 200 OK}
      {Server: JavaWebServer/2.0}
      {Set-Cookie: jwssessionid=PXV2VFYAAAAANQEBMQBQAAA;Path=/}
      {Cache-Control: no-cache="set-cookie,set-cookie2"}
      {Expires: Thu, 01 Dec 1994 16:00:00 GMT}
      {Content-Type: text/html}
      {Connection: close}
      {Date: Tue, 15 May 2001 19:29:58 GMT}

      Server http://127.0.0.1:8080/servlet/Untitled1 requesting to set-cookie with "jwssessionid=PXV2VFYAAAAANQEBMQBQAAA;Path=/"
      <html><body><form method="post" action="http://127.0.0.1:8080/servlet/Untitled1">
      <input type="submit" name="doPost" value="Do Post" />
      </form>
      <embed
      code='mozilla_session_bug.UntitledApplet'
      align='baseline'
      type='application/x-java-applet;version=1.3'
      width='100%' url='http://127.0.0.1:8080/servlet/Untitled1&#39;>
      <noembed>No support for Java 2 applets </noembed> </embed>
      </body></html>
      null
      Opening http://127.0.0.1:8080/servlet/Untitled1
      Connecting http://127.0.0.1:8080/servlet/Untitled1 with proxy=arago.eng.sun.com:8070
      debug: edburns: HttpClient.writeRequests:
      www.MessageHeader@27508a'>sun.net.www.MessageHeader@27508a
      {POST /servlet/Untitled1 HTTP/1.1: null}
      {Content-Type: text/xml}
      {User-Agent: Java1.3.1-rc1}
      {Host: 127.0.0.1:8080}
      {Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}
      {Connection: keep-alive}
      {Content-length: 7}
      {null: null}
      debug: edburns: HttpClient.parseHTTPHeader:
      www.MessageHeader@18cb3d'>sun.net.www.MessageHeader@18cb3d
      {null: HTTP/1.1 200 OK}
      {Server: JavaWebServer/2.0}
      {Set-Cookie: jwssessionid=PXV3FBYAAAAAPQEBMQBQAAA;Path=/}
      {Cache-Control: no-cache="set-cookie,set-cookie2"}
      {Expires: Thu, 01 Dec 1994 16:00:00 GMT}
      {Content-Type: text/html}
      {Connection: close}
      {Date: Tue, 15 May 2001 19:29:59 GMT}
      Server http://127.0.0.1:8080/servlet/Untitled1 requesting to set-cookie with "jwssessionid=PXV3FBYAAAAAPQEBMQBQAAA;Path=/"
      Oiii! The session lost the correct value
      null

      You can see the Set-Cookie header coming back as a result of the first GET, but you don't see it going out on the following POST request.

      What is to be done?

      I've attached the Servlet, Applet, and HTML.

            dgu Dennis Gu (Inactive)
            ejburns Ed Burns (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: