You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by ed cole <ed...@yahoo.com> on 2004/05/17 21:20:08 UTC

Redirect Question

Hi 
   I have a problem, I'm using HttpClient to connect to a website.  The 
intial page contains a redirect, I think through JavaScript, which spawns a new
browser.  I need to get to the ne wbrowser to login.  The initial HttpClient invocation return a status code 200, I don't even see the
3xx redirect code never mind the Response's Location value.
 
   Any ideas?
 
 
                                          Thanks


		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: Redirect Question

Posted by ed cole <ed...@yahoo.com>.
Chris
 
     Just wanted to thank you again for your help, you've helped my quite a bit.
 
 


Chris Lamprecht <cl...@elitemail.org> wrote:
Do you mean the JavaScript is included, perhaps using an HTML tag like the
following?

src="/system/utd_jscript.js">

(there may be other ways to include javascript source, I'm not an
HTML/javascript expert)

If this is the case, you should be able to request the included javascript
source file from the web server just as you would any other file, either
using HttpClient, or using your own browser (if you don't expect the
JavaScript file to change much). Then you can read the redirect location
from the contents of the JavaScript file.

----- Original Message ----- 
From: "ed cole" 
To: "Commons HttpClient Project" 
Sent: Monday, May 17, 2004 6:11 PM
Subject: Re: Redirect Question


> Chris
>
> Thanks for the reply, unfortunately I can't see the Javascript content
since it's loaded
> as a JavaScript source file. Do I have any other options.
>
> Thanks
>


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

		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: Redirect Question

Posted by Chris Lamprecht <cl...@elitemail.org>.
Do you mean the JavaScript is included, perhaps using an HTML tag like the
following?

<script language="javascript" type="text/javascript"
src="/system/utd_jscript.js"></script>

(there may be other ways to include javascript source, I'm not an
HTML/javascript expert)

If this is the case, you should be able to request the included javascript
source file from the web server just as you would any other file, either
using HttpClient, or using your own browser (if you don't expect the
JavaScript file to change much).  Then you can read the redirect location
from the contents of the JavaScript file.

----- Original Message ----- 
From: "ed cole" <ed...@yahoo.com>
To: "Commons HttpClient Project" <co...@jakarta.apache.org>
Sent: Monday, May 17, 2004 6:11 PM
Subject: Re: Redirect Question


> Chris
>
> Thanks for the reply, unfortunately I can't see the Javascript content
since it's loaded
> as a JavaScript source file.  Do I have any other options.
>
>      Thanks
>


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


Re: Redirect Question

Posted by ed cole <ed...@yahoo.com>.
Chris
 
Thanks for the reply, unfortunately I can't see the Javascript content since it's loaded
as a JavaScript source file.  Do I have any other options.
 
     Thanks

Chris Lamprecht <cl...@elitemail.org> wrote:
Hi Ed,
It depends on the content of the page returned. You can look at the
actual content returned (which should contain the JavaScript), and parse out
the redirect location. It may look something like this:

self.location.replace("/app/self-registration");

Then you can do a GET or POST (using HttpClient) to the redirect URL (which
may be relative, as in the example above). Hope this helps.

-Chris

----- Original Message ----- 
From: "ed cole" 
To: 
Sent: Monday, May 17, 2004 2:20 PM
Subject: Redirect Question


> Hi
> I have a problem, I'm using HttpClient to connect to a website. The
> intial page contains a redirect, I think through JavaScript, which spawns
a new
> browser. I need to get to the ne wbrowser to login. The initial
HttpClient invocation return a status code 200, I don't even see the
> 3xx redirect code never mind the Response's Location value.
>
> Any ideas?
>
>
> Thanks
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.


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

		
---------------------------------
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.

Re: Redirect Question

Posted by Chris Lamprecht <cl...@elitemail.org>.
Hi Ed,
     It depends on the content of the page returned.  You can look at the
actual content returned (which should contain the JavaScript), and parse out
the redirect location.  It may look something like this:

self.location.replace("/app/self-registration");

Then you can do a GET or POST (using HttpClient) to the redirect URL (which
may be relative, as in the example above).  Hope this helps.

-Chris

----- Original Message ----- 
From: "ed cole" <ed...@yahoo.com>
To: <co...@jakarta.apache.org>
Sent: Monday, May 17, 2004 2:20 PM
Subject: Redirect Question


> Hi
>    I have a problem, I'm using HttpClient to connect to a website.  The
> intial page contains a redirect, I think through JavaScript, which spawns
a new
> browser.  I need to get to the ne wbrowser to login.  The initial
HttpClient invocation return a status code 200, I don't even see the
> 3xx redirect code never mind the Response's Location value.
>
>    Any ideas?
>
>
>                                           Thanks
>
>
>
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! - Internet access at a great low price.


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


Question about cookies and Netscape-Enterprise/6.0 server

Posted by Chris Lamprecht <cl...@elitemail.org>.
I'm using HttpClient 2.0-final to do a form-based login to a
Netscape-Enterprise 6.0 server (according to the HTTP headers).  It uses
cookies to maintain the session.

When I run HttpClient in RFC2109 cookie mode, it works fine.  However, when
I switch it to either compatibility or NETSCAPE_DRAFT mode, the server seems
to ignore the cookies that HttpClient sends it.  (The server acts like the
client isn't logged in).

I used Mozilla's LiveHTTPHeaders plugin to see what Mozilla sends when I log
in using Mozilla , and the Cookie: header line is as follows:

Cookie: NSC_vuejsfdu_443=c0a8061300bb;
FC=AQEBBwID6QIQRUYzQjVGQjIxxEYzNEY0OQMJY2wxMCAgICAgBAoxMDg0OTQ5Mzk0BQ02Ni4yN
S4xMzUuMTg0BgQwU1RBCgFZCxhDaHJpc3RvcGhlciBNIExhbXByZWNodCAIgK91mi9dn0bezpWdS
OT6xTLQtpKhlyRPYs+k2+fO0fTNBQmoYD3bgefyNTlxIxRxk9p86yrOPn27LNkhUeliJlg/X+oa5
/KZ0HAWOMUIK9OvJ6yFab7WZBR1Tll6TM85yriPLSBMpNSDsV03jEkHw/h7MqRztV9EVjsU92zJG
cj/; TS=20040519011947;
SC=AQEBBwID6QIQRUYzQjVGQjIxxEYzNEY0OQYkMUU0RUE1NzA2QzQ2M0E2NkY2MUY3RDg4MDA5M
jk5MUU5MzVBBAoxMDg0OTQ5Mzk0BQ02Ni4yNS4xMzUuMTg0CgFZCIC9uBG2A5H+exOVvOEm72d9X
4oikfjht7oIFztnGUU8xmXwnFCa7XQvy/cazgK1LTePofwUKhKD//izihmmqv6RlNpdbowSa0h8D
XZtqNFKtbUj8PP5Jk9y7ZKiiRKWXYx20tlQUlo5Iig0Ts9qizm6q8PamYursfYK9lielyXPYQ==;
PDLK=NONE; DOC=/registrar/reg/Pregistration.WBX

(That should all be on a single line).

The only difference I can see in HttpClient's wire log is that it puts one
cookie per line, and it doesn't end each cookie with a semicolon:

>> "GET /registrar/reg/Pregistration.WBX HTTP/1.1[\r][\n]"
>> "Accept: image/gif, image/x-xbitmap, image/jpeg, */*[\r][\n]"
>> "Accept-Language: en-us[\r][\n]"
>> "Accept-Encoding: gzip, deflate[\r][\n]"
>> "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
1.0.3705)[\r][\n]"
>> "Host: xxxxx.yyyyy.edu[\r][\n]"
>> "Cookie: DOC=/index.html[\r][\n]"
>> "Cookie: PDLK=NONE[\r][\n]"
>> "Cookie:
SC=AQEBBwID6QIQRUYzQjVGQjIxNEYzNEY0OQYkOEM2RTI3RUM3MjQ4RDk4NTE5MDg5N0Y5QzhBQ
UVBODRCNjBDBAoxMDg0OTUwNTIzBQ02Ni4yNS4xMzUuMTg0CgFZCICgWfx0cCCdeTwbxBYeff42i
fXV/WWc26YqHzXnfl4CDNQazbhF3obVB6ve7SXMawMqHHfsPgcIpEbr5K5UjEcQyHO365s2OWnez
4ZiKiTtCS/dmHp+s8i5EIU/BiBJfUMmRxZ31Ll38js0OpUo5P518rZoN8g9waJCjfY2nm/kNg==[
\r][\n]"
>> "Cookie: TS=20040519013842[\r][\n]"
>> "Cookie:
FC=AQEBBwID6QIQRUYzQjVGQjIxNEYzNEY0OQMJY2wxMCAgICAgBAoxMDg0OTUwNTIzBQ02Ni4yN
S4xMzUuMTg0BgQwU1RBCgFZCxhDaHJpc3RvcGhlciBNIExhbXByZWNodCAIgLex5Xy9IKo6MG5SN
qeXcvQkqkm2SWeN50sDjvhWSAQPf1DKYpJaHaF2QF7NhQ8XyXVyDJmXzFz17wTPUUu6d/eqfoWmT
+J1N9gqycS7SjT8mb+7FPMoCxbt6iMiux0Gx40Gkepxbu+w3MhK+6FM549oWVGqgTSrHqL8+xgbT
3x3[\r][\n]"
>> "Cookie: NSC_vuejsfdu_443=c0a8061301bb[\r][\n]"

(Note:  I am intentionally setting the headers to appear like a normal
browser; that's why it says MSIE for User-Agent)

Any ideas why the server only recognizes RFC2109?

This isn't necessarily a big problem for me, since RFC2109 works, but I'm
trying to emulate a browser as _exactly_ as possible.  Thanks for your help.

Chris


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