You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Gajo Csaba <gc...@freemail.hu> on 2005/09/01 15:32:22 UTC
Website says "my browser doesn't support cookies"
Hi,
I'm trying to log in to www.monsterpapers.com using HttpClient. I've
tracked down all the fields that I need to send to the server, and after I
POST this to the login page, I get an error saying that my browser
doesn't have the cookies turned on.
Probably the Web site is using some incompatible system to send
cookies? This is the source code I've been trying:
==========================
post = new PostMethod("http://www.monsterpapers.com/Login/?
cookie=");
NameValuePair[] data = {
new NameValuePair("__VIEWSTATE", ""),
new NameValuePair("_ctl1:loginLogin:textEmail", userName),
new NameValuePair("_ctl1:loginLogin:textPassword", password),
new NameValuePair("_ctl1:loginLogin:buttonLogin", "Login")
};
post.getParams().setCookiePolicy(CookiePolicy.
BROWSER_COMPATIBILITY);
client.getParams().setCookiePolicy(CookiePolicy.
BROWSER_COMPATIBILITY);
post.setRequestBody(data);
post.setDoAuthentication(true);
client.executeMethod(post);
==========================
I have tried using BROWSER_COMPATIBILITY, DEFAULT and RFC_2109
but in all cases I got the same error page as the result of my POST.
I'm not really sure if it's the server that's incompatible. If this is the
error, then is there a way to solve this? I also tried setting the http.
protocol.single-cookie-header property to true, but this didn't help.
Could someone perhaps look at the login page to see why this is
happenning? I noticed that there are a few things happenning:
if in post = new PostMethod(<string>) instead of <string> I write:
http://www.monsterpapers.com/Login/?cookie=
then I get the result I've just been telling about. If I write
http://www.monsterpapers.com/Login/
then I get a page saying I should go to ?cookie= page
However, in the browser the POST is ALWAYS sent to /Login/ and not /
Login/?cookie= I checked with FireFox Live HTTP Headers to see if
there's redirecting going on, but there isn't. The information is sent to /
Login/ so how come it works with FireFox (and IE) but not with the
HttpClient ?
I tried pretending that I'm actually FireFox. I set http.useragent to
FireFox's string, but this ended up in an exception, right after it again
said my browser doesn't support cookies.
Any ideas?
Thanks, Csaba
_______________________________________________________________________
[freemail] extra 1GB-os postafiókkal, Önnek már van? http://freemail.hu
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Website says "my browser doesn't support cookies"
Posted by Gajo Csaba <gc...@freemail.hu>.
OK nevermind, I found the problem. I cleared the cookies in FireFox, and
then I saw what was really going on. First I need to log in, then the
server will set the cookie, and redirect me to /Login/?cookie= and then
this page will redirect me back to /Login/ and I have to send the login
information again to this page, and this time I won't get any error
messages, cause the previous time I visited this page my cookies were
set.
I wonder what the site author was thinking...?
Csaba
_______________________________________________________________________
[freemail] extra 1GB-os postafiókkal, Önnek már van? http://freemail.hu
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org