[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] [ htmlunit-Bugs-2973040 ] Cookie value received with
From:       "SourceForge.net" <noreply () sourceforge ! net>
Date:       2010-03-30 9:21:03
Message-ID: E1NwXd9-0006yE-Qb () sfs-web-7 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Bugs item #2973040, was opened at 2010-03-19 10:06
Message generated for change (Comment added) made by mguillem
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=2973040&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: https://www.google.com/accounts ()
Assigned to: Nobody/Anonymous (nobody)
Summary: Cookie value received with quotes should be sent with quotes

Initial Comment:
Hi

I have encountered following issue with HTMLUnit

when a web page sets a cookie with content like this "abc= xyz==" then on next \
request the cookie content is returned a "abc" only.

I have created a small test case to reproduce the issue. It consists of:
test.jsp -> I deployed it on tomcat server
Test.java -> it uses the HTMLUnit runtime to access the test.jsp twice:
  - first time with parameter "set=true" which makes the jsp set a cookie with \
                content "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa= \
                xxxxxxxxxxxxxxxxxxxxxxxxxx=="
  - second time without any parameters which causes the jsp to just print the cookies \
in the response. then prints the response.

What I get as an output is:
	     Cookie: JSESSIONID=5B86DFB5499D915BCFC9B3338C295224</br>

	     Cookie: test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</br>

as you can see the second cookie is cut.

Thank you
Vasil

----------------------------------------------------------------------

> Comment By: Marc Guillemot (mguillem)
Date: 2010-03-30 11:21

Message:
You're right, this seems to be only one part of the problem. Nevertheless
in your example the cookie header was sent with quotes (at least when I've
tested with Apache Tomcat) and HtmlUnit should handle "cookie quotes"
correctly.

----------------------------------------------------------------------

Comment By: https://www.google.com/accounts ()
Date: 2010-03-30 10:51

Message:
Hi
perhaps I cause a little confusion - the quotes around the cookie were
just meant to separate its value from the rest of the text. If you check
the coding posted after this you will see that there are no quotes around
the cookie value set.

In the light of this  - if you modify your test case like this:

  157     @Test
  158     @NotYetImplemented
  159     public void valueQuoted() throws Exception {
  160         final List<NameValuePair> responseHeader = new
ArrayList<NameValuePair>();
  161         responseHeader.add(new NameValuePair("Set-Cookie",
"key=value"));
  162         responseHeader.add(new NameValuePair("Set-Cookie", "test=aa=
xx=="));
  163         getMockWebConnection().setResponse(getDefaultUrl(), "", 200,
"OK", "text/html", responseHeader);
  164         getMockWebConnection().setDefaultResponse("");
  165 
  166         final WebDriver driver =
loadPageWithAlerts2(getDefaultUrl());
  167 
  168         driver.get(URL_SECOND.toExternalForm());
  169 
  170         assertEquals("key=value; test=aa= xx==",
getMockWebConnection().getLastAdditionalHeaders().get("Cookie"));
  171     }

it will continue to fail

(original coding taken from:
http://htmlunit.svn.sourceforge.net/viewvc/htmlunit/trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java?revision=5607&view=markup
 )

so it is not just the quotes - any cookie sent with a space inside will
not be sent back correctly.

Best regards
Vasil


----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2010-03-22 17:46

Message:
This is a problem of quotes in cookie values: cookies received with quotes
should be sent with quotes again to the server:
Set-Cookie: my_key="Hello"

This is a problem in HttpClient, perhaps can we implement a workaround.

Added test (as NotYetImplemented): CookieManagerTest#valueQuoted

----------------------------------------------------------------------

Comment By: https://www.google.com/accounts ()
Date: 2010-03-19 10:43

Message:
Further comment - I also tested it on 2.7 - reproducible there too.

----------------------------------------------------------------------

Comment By: https://www.google.com/accounts ()
Date: 2010-03-19 10:08

Message:
Hi again...
sorry I failed to attach the files and I don't find a way to attach it
now. So here is the coding:

test.jsp:

<%@ page import="javax.servlet.http.*" %>

<% 
	if (request.getParameter("set") != null) {
	  Cookie cookie = new Cookie("test",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa= xxxxxxxxxxxxxxxxxxxxxxxxxx==");
	  response.addCookie(cookie);
	} else {
	  Cookie[] cookies = request.getCookies();
	  if (cookies == null) {
%>
       No cookies
<%
	  } else {
	    for (int i = 0; i < cookies.length; i++) {
%>
	     Cookie: <%=cookies[i].getName()%>=<%=cookies[i].getValue()%></br>
<%
	    }
      }
	
	}

%>



Test.java:

import com.gargoylesoftware.htmlunit.*;

public class Test {
  public static void main(String[] args) throws Exception {
    WebClient client = new WebClient();
    HtmlPage page = client.getPage("http://localhost/test.jsp?set=true");
    page = client.getPage("http://localhost/test.jsp");
    System.out.println(page.getWebResponse().getContentAsString());
  }
}

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=2973040&group_id=47038

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic