RE: Re: get and send Cookie not working....

2007-08-20 Thread Mitch Stewart
Regis,
 
We've used the cookie feature in both Jetty and Tomcat (version 5.5.23).
While testing, we found that if the cookie information was not set
correctly, then the cookies would not be sent back to the server because
of browser security implementations. Here are some things which
prevented us from getting cookies...and we subsequently had to set them
when we created the cookie:
 
1. The cookie Path attribute wasn't set correctly, or wasn't set at all.
If this is not set, then the cookie will not be returned on subsequent
requests because the paths do not match. When we created client-side
cookies with javascript, we noticed that no Path attribute was set. Once
we did that it worked. You can set it to a specific relative path within
your URL structure..or you can set it to / for all URLs going to your
restlet code.
 
2. The cookie Domain attribute wasn't set correctly, or wasn't set at
all. This might not be the problem you are encountering, but if you try
to access data across subdomains from your browser it won't pass the
cookies around unless the domain is set to .mydomain.com where
mydomain.com is your base domain. Notice the dot . in front of the
domain name.
 
Also...have you tried to debug your restlet app and inspect the Request
object coming in? You can drill down into the actual headers that are
coming from your client to see if the Cookie header is even set with the
appropriate values..
 
Mitch



From: Regis Leray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 19, 2007 3:34 PM
To: discuss@restlet.tigris.org
Subject: Re: get and send Cookie not working


I did what you said i download the extensions for firefox, so it seems
the restlet filter send back a cookie to my browser. I m not at my
office desk so i cannot show you the message, but i will on monday, but
the cookie it is send. 

Could you tell me if some issue exist with firefox or IE ??

I said a mistake, i can't get any cookie from the request
(request.getCookies()) but the function doesn't return a null list but a
empty list, even i have some cookies which exists 

I will post the reponse on monday the reponse i get with http header
extension...
Somebody test the cookie feature in a tomcat container ??? (developper ,
user )

Thanks for the reply.
Regis



2007/8/17, Alex Milowski [EMAIL PROTECTED]: 

On 8/17/07, Regis Leray [EMAIL PROTECTED] wrote:
 private Cookie hasCookie(Request request) {

 ListCookie cookies = request.getCookies (); //always
NULL

The getCookies() call should not return a null value.

snip/


 About my environment all of this it is run in a tomcat
container, and i use
 the restlet version 1.0.4.

There could be an environment issue.  Have you tried running
your application
outside of Tomcat using the Simple or Jetty connectors?

Have you checked the return headers using the LiveHttpHeaders
[1] or 
my Poster [2]
extension for Firefox to see if the Set-Cookie header is there?

[1] https://addons.mozilla.org/en-US/firefox/addon/3829
[2] https://addons.mozilla.org/en-US/firefox/addon/2691

--Alex Milowski





-- 
Regis LERAY   
1214, rue Bishop 
Canada, Montreal (Qc) H3G 2E3
Cel: (514) 699 1000 


RE: Re: Re: get and send Cookie not working....

2007-08-20 Thread Mitch Stewart
You have it now, the browser will only send cookies back that match the
domain you are requesting. You will not need to set domain/path if you
are creating cookies in the restlet code as long as you hit the right
domain in the browser.
 
Mitch


but if you try with
http://127.0.0.1:8080/restlet/test (you can get the cookie) or
with a default domain name define in you
WINDOWS/system32/drivers/etc/host ( test.domain.com)
http://test.domain.com:8080/restlet/test
You can get the cookie in your browser.  

And the second time when i hit my application, i can get the
cookie in my filter ! I said another mistake, i thought i will get all
my cookies of my browser. But NOT, it is a security issue, so it was
normal, i didn't get the others cookies. 

Now when i get my cookie, i just have in the object the name 
the value, not the domain and the path (but i think that is a default
behavior). Tell me if it is not true.

Thanks a lot.
Bye regis.




Re: get and send Cookie not working....

2007-08-19 Thread Regis Leray
I did what you said i download the extensions for firefox, so it seems the
restlet filter send back a cookie to my browser. I m not at my office desk
so i cannot show you the message, but i will on monday, but the cookie it is
send.

Could you tell me if some issue exist with firefox or IE ??

I said a mistake, i can't get any cookie from the request (
request.getCookies()) but the function doesn't return a null list but a
empty list, even i have some cookies which exists

I will post the reponse on monday the reponse i get with http header
extension...
Somebody test the cookie feature in a tomcat container ??? (developper ,
user )

Thanks for the reply.
Regis


2007/8/17, Alex Milowski [EMAIL PROTECTED]:

 On 8/17/07, Regis Leray [EMAIL PROTECTED] wrote:
  private Cookie hasCookie(Request request) {
 
  ListCookie cookies = request.getCookies(); //always NULL

 The getCookies() call should not return a null value.

 snip/

 
  About my environment all of this it is run in a tomcat container, and i
 use
  the restlet version 1.0.4.

 There could be an environment issue.  Have you tried running your
 application
 outside of Tomcat using the Simple or Jetty connectors?

 Have you checked the return headers using the LiveHttpHeaders [1] or
 my Poster [2]
 extension for Firefox to see if the Set-Cookie header is there?

 [1] https://addons.mozilla.org/en-US/firefox/addon/3829
 [2] https://addons.mozilla.org/en-US/firefox/addon/2691

 --Alex Milowski




-- 
Regis LERAY
1214, rue Bishop
Canada, Montreal (Qc) H3G 2E3
Cel: (514) 699 1000


get and send Cookie not working....

2007-08-17 Thread Regis Leray
I dont understand, i try to send a cookie to my client browser (firefox, IE6
) but it doesn't seems to work.

so it is pretty simple i have a filter and a router


(*filter*1) --- router - [handler1]
   |
   |-- [handler2]




So here my filter


MyFilter extends Filter {

//= IN DEBUGMODE I SAW ANY COOKIES in the request object, but in my
firefox browser or IE
// i have many cookies which came from my personal usage
public void beforeHandle(Request request, Response response) {
Cookie cookie = null;

if ((cookie = hasCookie(request)) != null) {
String hash = cookie.getValue();
 .
}
}

public void doHandle(Request request, Response response) {
super.doHandle(request, response);
}


//= I put in the response object the cookie, so by defautl it shoud
send the cookie to my browser
public void afterHandle(Request request, Response response) {

if (hasCookie(request) == null) {
CookieSetting cookie = new CookieSetting(COOKIE_VERSION,
COOKIE_HASH, session.getHash(), COOKIE_PATH,
request.getHostRef().getIdentifier());

cookie.setMaxAge(0);
cookie.setSecure(false);
response.getCookieSettings().add(cookie);
}
}


private Cookie hasCookie(Request request) {

ListCookie cookies = request.getCookies(); //always NULL

for (Cookie cookie : cookies) {

if (cookie.getPath().equals(COOKIE_PATH)
 cookie.getVersion() == COOKIE_VERSION.intValue()
 cookie.getDomain().equals(request.getHostRef
().getIdentifier())
 cookie.getName().equals(COOKIE_HASH)
 cookie.getValue().length()  1) {
return cookie;
}

}

return null;

}

}


Could you tell me what's wrong with my code ?
My goal it is to send a cookie to my client if it doesn't exist...

About my environment all of this it is run in a tomcat container, and i use
the restlet version 1.0.4.

thanks for your reply.




-- 
Regis LERAY


Re: get and send Cookie not working....

2007-08-17 Thread Alex Milowski
On 8/17/07, Regis Leray [EMAIL PROTECTED] wrote:
 private Cookie hasCookie(Request request) {

 ListCookie cookies = request.getCookies(); //always NULL

The getCookies() call should not return a null value.

snip/


 About my environment all of this it is run in a tomcat container, and i use
 the restlet version 1.0.4.

There could be an environment issue.  Have you tried running your application
outside of Tomcat using the Simple or Jetty connectors?

Have you checked the return headers using the LiveHttpHeaders [1] or
my Poster [2]
extension for Firefox to see if the Set-Cookie header is there?

[1] https://addons.mozilla.org/en-US/firefox/addon/3829
[2] https://addons.mozilla.org/en-US/firefox/addon/2691

--Alex Milowski