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 Contay <co...@gmail.com> on 2007/06/03 01:59:00 UTC

post/redirect..

Hello, I have used HttpClient on one other program for logging into a site
(using post), and it worked perfectly (after following a redirect after the
post).
I am having problems doing the same exact thing for another site.  I perform
the post, get a re-direct, follow that, but result in a "The server
encountered and unexpected condition which prevented it from fulfilling the
request".

any help would be GREATLY appreciated! I am pretty much doing exactly as i
did in my other program, yet can't get logged in!! Please let me know if you
would like additional information from me in order to solve this...this is
really buggin me, and I can't figure it out.  thanks in advance to anyone
who's able to help!

 below I am pasting the debug from the post part and anything after

prior to the POST, I merely set up a client with
getHostConfiguration().setHost(www.pacificare, 443, "https")
then I do a GET to
/commonPortal/link?product=Commercial&audience=Provider-Before-Logon&region=CA&navnode=PacifiCareProviderLogin
then a GET to /mphs/fcc2/login.fcc
and then the POST, etc..
I do the two gets because if i go to the /mphs/fcc2/login.fcc with a browser
and try to log in, it doesn't work.  But by first going to the first page
and then the second, I am able to log in.



DEBUG [httpclient.wire.header] >> "POST /mphs/fcc2/login.fcc
HTTP/1.1[\r][\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Adding Host request
header
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Default charset used:
ISO-8859-1
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Default charset used:
ISO-8859-1
DEBUG [httpclient.wire.header] >> "User-Agent: MSIE 6.0[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host:
www.pacificare.com[\r][\n<http://www.pacificare.com[/r][/n>
]"
DEBUG [httpclient.wire.header] >> "Content-Length: 122[\r][\n]"
DEBUG [httpclient.wire.header] >> "Content-Type:
application/x-www-form-urlencoded[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.content] >>
"user_prefix=ansfa&user_suffix=&password=abc123&target=%2FcommonPortal%2Fprovider%2Floginhandler&username=ansfa&fpR
egion=CA"
DEBUG [org.apache.commons.httpclient.methods.EntityEnclosingMethod] Request
body sent
DEBUG [httpclient.wire.header] << "HTTP/1.0 302 Found[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Sat, 02 Jun 2007 23:26:10
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Apache/2.0.54 (Unix) mod_jk/1.2.6
mod_ssl/2.0.54 OpenSSL/0.9.7c DAV/2[\r][\n]"
DEBUG [httpclient.wire.header] << "Set-Cookie:
FORMCRED=4DCH6tB3DmeNIB1j9AhlEaFu8QrMtpTcHe4JFu7cRvEeDRN+H+4C/23Yuo9oReQeEBZlbctXgTgzYzO6bkJlXT6WTCso4l
Gw3rgxFdalAXWw847qNBrTu+wc+krQtQeiuFMTYch4qRVQiwQp1LaZsbZICoM2Sjtm; path=/;
domain=.pacificare.com[\r][\n]"
DEBUG [httpclient.wire.header] << "Cache-Control: no-cache[\r][\n]"
DEBUG [httpclient.wire.header] << "Location:
/commonPortal/provider/loginhandler[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Length: 351[\r][\n]"
DEBUG [httpclient.wire.header] << "Connection: close[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Type: text/html;
charset=iso-8859-1[\r][\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Cookie accepted:
"$Version=0;
FORMCRED=4DCH6tB3DmeNIB1j9AhlEaFu8QrMtpTcHe4JFu7cRvEeDRN+H+4C/23Yuo
9oReQeEBZlbctXgTgzYzO6bkJlXT6WTCso4lGw3rgxFdalAXWw847qNBrTu+wc+krQtQeiuFMTYch4qRVQiwQp1LaZsbZICoM2Sjtm;
$Path=/; $Domain=.pacificare.com"
DEBUG [org.apache.commons.httpclient.HttpMethodDirector] Redirect required
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Buffering response body
DEBUG [httpclient.wire.content] << "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
2.0//EN">[\n]"
DEBUG [httpclient.wire.content] << "<html><head>[\n]"
DEBUG [httpclient.wire.content] << "<title>302 Found</title>[\n]"
DEBUG [httpclient.wire.content] << "</head><body>[\n]"
DEBUG [httpclient.wire.content] << "<h1>Found</h1>[\n]"
DEBUG [httpclient.wire.content] << "<p>The document has moved <a
href="/commonPortal/provider/loginhandler">here</a>.</p>[\n]"
DEBUG [httpclient.wire.content] << "<hr>[\n]"
DEBUG [httpclient.wire.content] << "<address>Apache/2.0.54 (Unix)
mod_jk/1.2.6 mod_ssl/2.0.54 OpenSSL/0.9.7c DAV/2 Server at
www.pacificare.com Port 4
43</address>[\n]"
DEBUG [httpclient.wire.content] << "</body></html>[\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Should close connection
in response to directive: close
DEBUG [org.apache.commons.httpclient.HttpConnection] Releasing connection
back to connection manager.
DEBUG [org.apache.commons.httpclient.HttpConnection] Open connection to
www.pacificare.com:443
DEBUG [httpclient.wire.header] >> "GET /commonPortal/provider/loginhandler
HTTP/1.1[\r][\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Adding Host request
header
DEBUG [httpclient.wire.header] >> "User-Agent: MSIE 6.0[\r][\n]"
DEBUG [httpclient.wire.header] >> "Host:
www.pacificare.com[\r][\n<http://www.pacificare.com[/r][/n>
]"
DEBUG [httpclient.wire.header] >> "Cookie: $Version=0;
JSESSIONID_CP=Gh8P1ZQjGmpp2scx8LLV7QG14ZLnJ9h2tK2zYZPLqlCny5vrb0vj!2131839350!-642015345;
$Path
=/commonPortal[\r][\n]"
DEBUG [httpclient.wire.header] >> "Cookie: $Version=0;
FORMCRED=4DCH6tB3DmeNIB1j9AhlEaFu8QrMtpTcHe4JFu7cRvEeDRN+H+4C/23Yuo9oReQeEBZlbctXgTgzYzO6bkJlXT
6WTCso4lGw3rgxFdalAXWw847qNBrTu+wc+krQtQeiuFMTYch4qRVQiwQp1LaZsbZICoM2Sjtm;
$Path=/; $Domain=.pacificare.com[\r][\n]"
DEBUG [httpclient.wire.header] >> "[\r][\n]"
DEBUG [httpclient.wire.header] << "HTTP/1.0 500 Internal Server
Error[\r][\n]"
DEBUG [httpclient.wire.header] << "Date: Sat, 02 Jun 2007 23:26:11
GMT[\r][\n]"
DEBUG [httpclient.wire.header] << "Server: Apache/2.0.54 (Unix) mod_jk/1.2.6
mod_ssl/2.0.54 OpenSSL/0.9.7c DAV/2[\r][\n]"
DEBUG [httpclient.wire.header] << "Set-Cookie: FORMCRED=; expires=Mon, 04
Dec 2006 23:26:11 GMT; path=/; domain=.pacificare.com[\r][\n]"
DEBUG [httpclient.wire.header] << "Set-Cookie:
SMSESSION=BmBro57EjECQ7ObTkPcTZAHPnRi44COXBgQasBVhWBnM/zYKf3d+DcSkVw53IcGfiSgWXxZDkqXoHvesL935tXu7O8Q/e
8IOgc5ty6O2WxO+o+AURscm/e6eaKPW4n8EYzJoFPM+PaHPwXmt71VbyasI0xttT14Qa7xTsJv0fpan71iPL1rzYyO+/bR6ctmv6Y9hsgCwPM7fUFOrxnpcuVr1WP9WHL3fJTtMqO6hZhyurAvr1kY
j999DF97wrbnDiKQJZQcutv2fJSVdS9KJlWXbd5rl1d/HfVPsZBNoRUW/qpARMWhi11LPY2nLCRpJxtxD22SHeCDu85rujO09hrLmXf9yOzjUTSDAsEKbPE5uSnqEn1r6SlphfaSP13MBzWS63hbMM
JbiPUc8MB7g1OeMISTuR1TNzD372+28BmDihVp6fImqsd4oSxhSwyMvH4V6VpKkjm/lKMpwZmx50YEn3LgJqqzjjqKTVy/gceSaB9oyBlhMCo1nt+mWpYppUSf+7dIUeapD6fU7p3okKANz3vuhkiU
Nzu9o42jy3GpraKQ98A5rV5YJOndZUH2lDK/npoCqFaKjrsOJPvClZi9oGynYoDPXSNv8G9XUobKFAvFqbz7WUx7cG4UAjxqkSAD3aBRGpHDqVbQ1ZPXzdbsuYO4LyNyZJDSa+AyDYj8HW7BTamzkT
0n92ArAH7eLqvba+lGWjuMAynEC8LAsgY11zduCMHcHnhMXDZk9u5dUrRhtsoTG3t0NaGa4dwmbNEHAW7dTaSEy1XdyBEJUuc/6hIWzpA6ZP2w07TH1g3U5sqNI297CedWJrEaTTwWzEyl1/b/eaDm
GPIICivRNnd4m8KnfhOeSko//dKCKLst8RfTIalpB5yyy341n5taX3AIT9hHxVWtDJ/ci+dh3KUWGIwjGZCKMu7qQG7I4k/QP0O5k5g/hFbM70e7ARWCVJbOLsybUcKVvpxk0cJlmfa/YerVybHsF;
 path=/; domain=.pacificare.com[\r][\n]"
DEBUG [httpclient.wire.header] << "Set-Cookie:
SMIDENTITY=oC/WKRQ/T8KRnLHwWkQhBjuqcvW6E5kn8gtZe2OTbIRKM1w9j9PD0cCMQnZ2AqjeSKYXqho7sEzLAQKS2H0ztnFlDyEz
ND+r6xDWhFq5jkRXshCzWJ4YOnWT42psNqM4ygDgtPIpmGaXSlr9y+T6DcBGPZtB8mlvfOp9BuBevC8iTUQ9PPstoc/tJ008cEe0gsWY+/PCScNQBstwmKmzsIV/n4vvgdJ38zXmX3Lw06kvmsFgz4
+4/qY0v+XT94cb8Wrde5k/BEp6IQpUxVObV5IkjQJd7S57UqWibxK+s4HD3a1f80rGAg3zb+m/g+wpNhcZPU1mun9Aghpn00fdNT4SMicaC81eDaBV30oHzNAw8oh7i74uKNLAdpQiTQgIsX8HQlOf
1Ak7aqNwEEvraqteS9VbnrtC2VW5Z4F4CxBIXMuWX98UiINHZBzBMiG4/YN/xeHLqnJ9X7gGifqpJ6zy/7K2JTRrYKDEIB6MZvRGiGBfn43DkrdxN+oKX4IrQSMseT+LrGacyC+fnnYH8aSTmAU9Ej
sqYhtqu62vt67zKnjU8l1cJaQ26XOfBm/jCfA1IdIQYdJl4IBTPuJvq2lZ10c5OCbpfwtPH11t0hZ6GNDuf7EQ8sV0McxMpNGH;
expires=Mon, 01 Jun 2009 23:26:11 GMT; path=/; dom
ain=.pacificare.com[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Length: 943[\r][\n]"
DEBUG [httpclient.wire.header] << "Connection: close[\r][\n]"
DEBUG [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Cookie accepted:
"$Version=0; FORMCRED=; $Path=/; $Domain=.pacificare.com"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Cookie accepted:
"$Version=0;
SMSESSION=BmBro57EjECQ7ObTkPcTZAHPnRi44COXBgQasBVhWBnM/zYKf3d+DcSkV
w53IcGfiSgWXxZDkqXoHvesL935tXu7O8Q/e8IOgc5ty6O2WxO+o+AURscm/e6eaKPW4n8EYzJoFPM+PaHPwXmt71VbyasI0xttT14Qa7xTsJv0fpan71iPL1rzYyO+/bR6ctmv6Y9hsgCwPM7fUFO
rxnpcuVr1WP9WHL3fJTtMqO6hZhyurAvr1kYj999DF97wrbnDiKQJZQcutv2fJSVdS9KJlWXbd5rl1d/HfVPsZBNoRUW/qpARMWhi11LPY2nLCRpJxtxD22SHeCDu85rujO09hrLmXf9yOzjUTSDAs
EKbPE5uSnqEn1r6SlphfaSP13MBzWS63hbMMJbiPUc8MB7g1OeMISTuR1TNzD372+28BmDihVp6fImqsd4oSxhSwyMvH4V6VpKkjm/lKMpwZmx50YEn3LgJqqzjjqKTVy/gceSaB9oyBlhMCo1nt+m
WpYppUSf+7dIUeapD6fU7p3okKANz3vuhkiUNzu9o42jy3GpraKQ98A5rV5YJOndZUH2lDK/npoCqFaKjrsOJPvClZi9oGynYoDPXSNv8G9XUobKFAvFqbz7WUx7cG4UAjxqkSAD3aBRGpHDqVbQ1Z
PXzdbsuYO4LyNyZJDSa+AyDYj8HW7BTamzkT0n92ArAH7eLqvba+lGWjuMAynEC8LAsgY11zduCMHcHnhMXDZk9u5dUrRhtsoTG3t0NaGa4dwmbNEHAW7dTaSEy1XdyBEJUuc/6hIWzpA6ZP2w07TH
1g3U5sqNI297CedWJrEaTTwWzEyl1/b/eaDmGPIICivRNnd4m8KnfhOeSko//dKCKLst8RfTIalpB5yyy341n5taX3AIT9hHxVWtDJ/ci+dh3KUWGIwjGZCKMu7qQG7I4k/QP0O5k5g/hFbM70e7AR
WCVJbOLsybUcKVvpxk0cJlmfa/YerVybHsF; $Path=/; $Domain=.pacificare.com"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Cookie accepted:
"$Version=0;
SMIDENTITY=oC/WKRQ/T8KRnLHwWkQhBjuqcvW6E5kn8gtZe2OTbIRKM1w9j9PD0cCM
QnZ2AqjeSKYXqho7sEzLAQKS2H0ztnFlDyEzND+r6xDWhFq5jkRXshCzWJ4YOnWT42psNqM4ygDgtPIpmGaXSlr9y+T6DcBGPZtB8mlvfOp9BuBevC8iTUQ9PPstoc/tJ008cEe0gsWY+/PCScNQBs
twmKmzsIV/n4vvgdJ38zXmX3Lw06kvmsFgz4+4/qY0v+XT94cb8Wrde5k/BEp6IQpUxVObV5IkjQJd7S57UqWibxK+s4HD3a1f80rGAg3zb+m/g+wpNhcZPU1mun9Aghpn00fdNT4SMicaC81eDaBV
30oHzNAw8oh7i74uKNLAdpQiTQgIsX8HQlOf1Ak7aqNwEEvraqteS9VbnrtC2VW5Z4F4CxBIXMuWX98UiINHZBzBMiG4/YN/xeHLqnJ9X7gGifqpJ6zy/7K2JTRrYKDEIB6MZvRGiGBfn43DkrdxN+
oKX4IrQSMseT+LrGacyC+fnnYH8aSTmAU9EjsqYhtqu62vt67zKnjU8l1cJaQ26XOfBm/jCfA1IdIQYdJl4IBTPuJvq2lZ10c5OCbpfwtPH11t0hZ6GNDuf7EQ8sV0McxMpNGH;
$Path=/; $Doma
in=.pacificare.com"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Buffering response body
DEBUG [httpclient.wire.content] << "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.0 Draft//EN">[\n]"
DEBUG [httpclient.wire.content] << "<HTML>[\n]"
DEBUG [httpclient.wire.content] << "<HEAD>[\n]"
DEBUG [httpclient.wire.content] << "<TITLE>Error 500--Internal Server
Error</TITLE>[\n]"
DEBUG [httpclient.wire.content] << "<META NAME="GENERATOR" CONTENT="WebLogic
htmlKona WebLogic Temporary Patch for CR127930 02/25/2005 03:56:02">[\n]"

DEBUG [httpclient.wire.content] << "</HEAD>[\n]"
DEBUG [httpclient.wire.content] << "<BODY bgcolor="white">[\n]"
DEBUG [httpclient.wire.content] << "<FONT FACE=Helvetica><BR CLEAR=all>[\n]"
DEBUG [httpclient.wire.content] << "<TABLE border=0
cellspacing=5><TR><TD><BR CLEAR=all>[\n]"
DEBUG [httpclient.wire.content] << "<FONT FACE="Helvetica" COLOR="black"
SIZE="3"><H2>Error 500--Internal Server Error</H2>[\n]"
DEBUG [httpclient.wire.content] << "</FONT></TD></TR>[\n]"
DEBUG [httpclient.wire.content] << "</TABLE>[\n]"
DEBUG [httpclient.wire.content] << "<TABLE border=0 width=100%
cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT
FACE="Courier New"><FO
NT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer
Protocol -- HTTP/1.1</i>:</H3>[\n]"
DEBUG [httpclient.wire.content] << "</FONT><FONT FACE="Helvetica"
SIZE="3"><H4>10.5.1 500 Internal Server Error</H4>[\n]"
DEBUG [httpclient.wire.content] << "</FONT><P><FONT FACE="Courier New">The
server encountered an unexpected condition which prevented it from fulfilli
ng the request.</FONT></P>[\n]"
DEBUG [httpclient.wire.content] << "</FONT></TD></TR>[\n]"
DEBUG [httpclient.wire.content] << "</TABLE>[\n]"
DEBUG [httpclient.wire.content] << "[\n]"
DEBUG [httpclient.wire.content] << "</BODY>[\n]"
DEBUG [httpclient.wire.content] << "</HTML>[\n]"
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Should close connection
in response to directive: close
DEBUG [org.apache.commons.httpclient.HttpConnection] Releasing connection
back to connection manager.
DEBUG [org.apache.commons.httpclient.HttpMethodBase] Default charset used:
ISO-8859-1

Re: post/redirect..

Posted by Roland Weber <RO...@de.ibm.com>.
Hello,

> I read the sections pertaining to cookies, and monitored what's going on
> (with the debug on).  It seems a session is being established correctly
> (same cookie being sent as was accepted).  my cookie for domain
> www.blah.comhas a path of '/somePath'.  Question...when I come to post
> my form, the
> target for my form is '/someOtherPath', so the cookie is never sent...is
> this a problem? but it seems to work fine, as i get a redirect location
> (which i don't get if i put in incorrect username/password..so i'm 
thinking
> the cookies are working as expected)..but then when i try to follow the
> redirect is when it gives me an error.  I don't see anything wrong with 
the
> debug statements.  Are there any common gotchas when it comes to
> redirects/cookies/etc?  Thanks in advance!!

Have you checked the Referer: header? It's also useful to take
a trace of a browser session for comparison. A network-level
tool for that purpose is wireshark (formerly ethereal).

hope that helps,
  Roland


Re: post/redirect..

Posted by Contay <co...@gmail.com>.
I read the sections pertaining to cookies, and monitored what's going on
(with the debug on).  It seems a session is being established correctly
(same cookie being sent as was accepted).  my cookie for domain
www.blah.comhas a path of '/somePath'.  Question...when I come to post
my form, the
target for my form is '/someOtherPath', so the cookie is never sent...is
this a problem? but it seems to work fine, as i get a redirect location
(which i don't get if i put in incorrect username/password..so i'm thinking
the cookies are working as expected)..but then when i try to follow the
redirect is when it gives me an error.  I don't see anything wrong with the
debug statements.  Are there any common gotchas when it comes to
redirects/cookies/etc?  Thanks in advance!!

On 6/3/07, Contay <co...@gmail.com> wrote:
>
> thanks for the response...i will pay more attention to the primer.
>
> On 6/3/07, Roland Weber <os...@dubioso.net> wrote:
> >
> > Hello,
> >
> > > Hello, I have used HttpClient on one other program for logging into a
> > site
> > > (using post), and it worked perfectly (after following a redirect
> > after the
> > > post).
> > > I am having problems doing the same exact thing for another site.
> >
> > There is no general solution to this problem. Every site can have a
> > different login procedure, different session handling, and whatever.
> > Please study our Client HTTP Programming Primer:
> > http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
> >
> > Give special care to the required parameters and the cookie handling.
> >
> > good luck,
> > Roland
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
>

Re: post/redirect..

Posted by Contay <co...@gmail.com>.
thanks for the response...i will pay more attention to the primer.

On 6/3/07, Roland Weber <os...@dubioso.net> wrote:
>
> Hello,
>
> > Hello, I have used HttpClient on one other program for logging into a
> site
> > (using post), and it worked perfectly (after following a redirect after
> the
> > post).
> > I am having problems doing the same exact thing for another site.
>
> There is no general solution to this problem. Every site can have a
> different login procedure, different session handling, and whatever.
> Please study our Client HTTP Programming Primer:
> http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
>
> Give special care to the required parameters and the cookie handling.
>
> good luck,
> Roland
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

Re: post/redirect..

Posted by Roland Weber <os...@dubioso.net>.
Hello,

> Hello, I have used HttpClient on one other program for logging into a site
> (using post), and it worked perfectly (after following a redirect after the
> post).
> I am having problems doing the same exact thing for another site.

There is no general solution to this problem. Every site can have a
different login procedure, different session handling, and whatever.
Please study our Client HTTP Programming Primer:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners

Give special care to the required parameters and the cookie handling.

good luck,
  Roland

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