Ok,
I change the user-agent to Mozilla:
httpget.addRequestHeader("User-Agent","Mozilla/4.0");

And cookiePolicy:
httpclient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILIT
Y);

And the next one is some trace:

Target URL: http://www-dev.fundacionolgatorres.org/index.php
Response status code: 200
Present cookies: 
 - PHPSESSID=23ed591387689e00636ec63a59a2248a expire: false
 - cookIdioma=2 expire: false

Request headers:

User-Agent: Mozilla/4.0
Cookie: PHPSESSID=23ed591387689e00636ec63a59a2248a
Cookie: cookIdioma=2
Host: www-dev.fundacionolgatorres.org

Response headers:

Date: Mon, 06 Feb 2006 15:20:53 GMT
Server: Apache
X-Powered-By: PHP/5.0.5
Set-Cookie: PHPSESSID=23ed591387689e00636ec63a59a2248a, cookIdioma=2;
path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1

This one returns a incorrect page.

But as i tell you before, if I remove the second cookie, The page
returned is ok.

Where is the error exactly in the header?

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:[EMAIL PROTECTED] 
Enviado el: lunes, 06 de febrero de 2006 15:33
Para: HttpClient User Discussion
Asunto: RE: Persistent connections

On Mon, 2006-02-06 at 12:47 +0100, Juan Luis de Amaya Robles wrote:
> Hi everybody,
> 
> Last week I wrate the mails below. 
> I think found the problem,...
> 
> When i run my program i get this response header:
> 
> 12:36:58: >> "GET /index.php HTTP/1.1[\r][\n]"
> 12:36:58: >> "Cookie:
> PHPSESSID=392f3d0db60fe8e2d77dd4dd4a30b84c[\r][\n]"
> 12:36:58: >> "Cookie: cookIdioma=2[\r][\n]"
> 12:36:58: >> "User-Agent: Jakarta Commons-HttpClient/3.0[\r][\n]"
> 12:36:58: >> "Host: www-dev.fundacionolgatorres.org[\r][\n]"
> 12:36:58: >> "[\r][\n]"
> 12:36:58: << "HTTP/1.1 200 OK[\r][\n]"
> 12:36:58: << "Date: Mon, 06 Feb 2006 11:31:43 GMT[\r][\n]"
> 12:36:58: << "Server: Apache[\r][\n]"
> 12:36:58: << "X-Powered-By: PHP/5.0.5[\r][\n]"
> 12:36:58: << "Set-Cookie: PHPSESSID=392f3d0db60fe8e2d77dd4dd4a30b84c,
> cookIdioma=2; path=/[\r][\n]"

This cookie header is invalid. I am not sure that causes the server to
send an invalid cookie in response to a request generated with
HttpClient, but these are things to try 

(1) Try using the browser compatibility policy instead of the default
one http://jakarta.apache.org/commons/httpclient/cookies.html

(2) Try masquerading HttpClient as a common browser
http://jakarta.apache.org/commons/httpclient/troubleshooting.html 

Oleg

> 12:36:58: << "Expires: Thu, 19 Nov 1981 08:52:00 GMT[\r][\n]"
> 12:36:58: << "Cache-Control: no-store, no-cache, must-revalidate, 
> post-check=0, pre-check=0[\r][\n]"
> 12:36:58: << "Pragma: no-cache[\r][\n]"
> 12:36:58: << "Transfer-Encoding: chunked[\r][\n]"
> 12:36:58: << "Content-Type: text/html; charset=ISO-8859-1[\r][\n]"
> 
> But if i run on firefox browser (for instance) i get:
> 
> Response Headers - http://www-dev.fundacionolgatorres.org/index.php
> 
> Date: Mon, 06 Feb 2006 11:38:02 GMT
> Server: Apache
> X-Powered-By: PHP/5.0.5
> Set-Cookie: PHPSESSID=23ed591387689e00636ec63a59a2248a; path=/
> Expires: Thu, 19 Nov 1981 08:52:00 GMT
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
> pre-check=0
> Pragma: no-cache
> Keep-Alive: timeout=15, max=100
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/html; charset=ISO-8859-1
> 
> Difference is in Set-Cookie line:
> 
> "Set-Cookie: PHPSESSID=392f3d0db60fe8e2d77dd4dd4a30b84c, cookIdioma=2;

> path=/[\r][\n]"
> 
> In firefox i don't get the cookIdioma=2
> 
> Why with "cookIdioma" doesn't work?
> 
> 
> 
> 
> -----Mensaje original-----
> De: Juan Luis de Amaya Robles
> Enviado el: viernes, 03 de febrero de 2006 9:02
> Para: 'HttpClient User Discussion'
> Asunto: RE: Persistent connections
> 
> Hi Roland,
> 
> Thank you for your answer.
> Yes, I use the same object. In fact, I've implemented the singleton
> pattern:
> 
> public class CookieDemoApp {
>       
>       private static CookieDemoApp _instance;
>     
>       private HttpClient httpclient;
> ...
> ...
> public static CookieDemoApp getInstance(){
>       if (_instance == null){
>               _instance = new CookieDemoApp();
>       }
>       return _instance;
>     }
>     
>     private CookieDemoApp(){
>       HttpState initialState = new HttpState();       
>       httpclient = new HttpClient();
>  
> httpclient.getHttpConnectionManager().getParams().setConnectionTimeout
> (3
> 0000);
>       httpclient.setState(initialState);
>  
> httpclient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBIL
> IT
> Y);
>     }
> 
> public void connect(String strURL) throws Exception {
>       System.out.println("Target URL: " + strURL);
>         
>         // Get HTTP GET method
>       GetMethod httpget = new GetMethod(strURL);
>       ...
>       ...
> 
> 
> And the caller is:
> 
> CookieDemoApp demo = CookieDemoApp.getInstance();
>       
> demo.connect("http://www-dev.fundacionolgatorres.org/estructura/idioma
> /c
> ambiar_idioma.php?Mg%3D%3D");
>       
> demo.connect("http://www-dev.fundacionolgatorres.org/index.php";);
> 
> 
> Prints to console, (sorry, the urls are not public):
> 
> Target URL:
>
http://www-dev.fundacionolgatorres.org/estructura/idioma/cambiar_idioma.
> php?Mg%3D%3D
> Response status code: 200
> Present cookies: 
>  - PHPSESSID=47b53d8001c9de9c25f6c877151a0566
>  - cookIdioma=2    <---- it means english language, so the cookie
> information is ok.
> 
> Target URL: http://www-dev.fundacionolgatorres.org/index.php
> Response status code: 200
> Present cookies: 
>  - PHPSESSID=47b53d8001c9de9c25f6c877151a0566
>  - cookIdioma=2       <--- ok
> Not found!    <--- it means the resulted page is incorrect. Returns
page
> in default language (spanish)
> 
> Any suggestions?
> Thanks again!
> 
> 
> -----Mensaje original-----
> De: Roland Weber [mailto:[EMAIL PROTECTED] Enviado el: viernes, 03 
> de febrero de 2006 7:22
> Para: HttpClient User Discussion
> Asunto: Re: Persistent connections
> 
> Hi Juan,
> 
> "Juan Luis de Amaya Robles" <[EMAIL PROTECTED]> wrote on
> 02.02.2006 19:48:50:
> 
> > I have two urls to call (PHP pages). One sets a language variable in

> > session. Another returns data depending on the session var.
> > 
> > i think, i need stablish persistent connection to connect web pages 
> > with session data.
> 
> No. If connections were persistent, you wouldn't need a session.
> 
> > When i call the first one url, it returns a cookie with a PHPSESSID 
> > (it's a php). ok.
> > I understand that cookie is sended when I call the second one url, 
> > but
> 
> > i get a incorrect second page, well, the language is not correct.
> > This is because the session is incorrect. I think.
> 
> Quite possible. Make sure you use the same HttpClient object for both 
> requests.
> Check out our cookie guide to see whether your problem is addressed
> there:
> 
> http://jakarta.apache.org/commons/httpclient/cookies.html
> 
> > When i print the "isPersistent()" method is returned false. I must 
> > configure anything else?
> > where the cookie is stored?
> 
> HttpClient never stores persistent cookies anywhere but in memory.
> By default, they are put into the state of the HttpClient object.
> Make sure you use the same HttpClient object for both request. Don't 
> pass an explicit state to the second request. Try the "browser 
> compatibility" cookie spec, since some servers send domain names 
> without a leading dot.
> 
> hope that helps,
>   Roland
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to