hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SrinivasaGandhi Sampath" <gan...@aalayance.com>
Subject RE: Cookie Troubles
Date Thu, 16 Oct 2003 09:51:52 GMT
I've been breaking my head with this same issue the past couple of days.
Looks like even some of the most popular servers send back invalid
cookies - some do this intermittently that makes preparing for a demo a
nightmare :-(

I also think the addition of CookiePolicy.IGNORE_COOKIES will be useful.
Still better could be to have a CookiePolicy.IGNORE_INVALID_COOKIES
setting that will just ignore the invalid cookies and return the valid
ones.

-Gandhi


> -----Original Message-----
> From: Oliver Köll [mailto:listen@quimby.de] 
> Sent: Thursday, October 16, 2003 3:05 PM
> To: commons-httpclient-dev@jakarta.apache.org
> Subject: Cookie Troubles
> 
> 
> This is my first appearance here - so, hi to all and thanks to the  
> Apache guys for all the nice work!
> 
> Now to my problems (using version 2.0 rc2):
> 
> I'm dealing with a site that serves invalid Cookies in 
> various kind of  
> ways. In some cases the Cookie values contain "," characters, which  
> really confuses the Header/Cookie parsers and eventually leads to  
> IllegalArgumentExceptions thrown by the Cookie constructor:
> 
> java.lang.IllegalArgumentException: Cookie name may not be blank
>    at org.apache.commons.httpclient.Cookie.<init>(Cookie.java:142)
>    at  
> org.apache.commons.httpclient.cookie.CookieSpecBase.parse(Cook
> ieSpecBase 
> .java:192)
>    at  
> org.apache.commons.httpclient.cookie.CookieSpecBase.parse(Cook
> ieSpecBase 
> .java:256)
>    at  
> org.apache.commons.httpclient.HttpMethodBase.processResponseHe
> aders(Http 
> MethodBase.java:1826)
>    at  
> org.apache.commons.httpclient.HttpMethodBase.readResponse(Http
> MethodBase 
> .java:1939)
>    at  
> org.apache.commons.httpclient.HttpMethodBase.processRequest(Ht
> tpMethodBa 
> se.java:2631)
>    at  
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMetho
> dBase.java 
> :1085)
>    at  
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpCli
> ent.java:6 
> 74)
>    at  
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpCli
> ent.java:5 
> 29)
>    at my.code.Test.getHttp(Test.java:114)
> 
> What bothers me, is that these IllegalArgumentExceptions are never  
> caught in the HttpClient code, making it effectivily impossible to  
> handle these responses.
> 
> My questions/suggestions:
> 
> 1) There are lots of IllegalArgumentExceptions thrown in 
> CookieSpecBase  
> and Cookie. These should be either caught, or replaced with (or  
> converted to) MalformedCookieExceptions, which are handled in  
> HttpMethodBase.
> 
> 2) Wouldn't it make sense to create an additional  
> CookiePolicy.IGNORE_COOKIES that disables cookie parsing? 
> This would be  
> useful, if you either do not care about Cookies or if they are so  
> messed up, that there is no hope parsing them.
> 
> 3) Finally, wouldn't it be nice to have the possibility to 
> plug-in your  
> own custom Cookie parser, allowing more control with 
> parsing/validating  
> bad Cookies? Something like
> 
>    HttpState.setCookiePolicy( CookiePolicy.CUSTOM, myCustomCookieSpec)
> 
> shouldn't be too difficult to implement.
> 
> Cheers,
> 
> Oliver
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message