Hi Luk, On paper your approach looks fine... The behavior you describe is strange. If you could send a reproducible sample code, that would help us pinpoint the exact issue.
Note, maybe you want to change "test Access Control" to a space-less string for the authentication realm. I'm not sure if spaces are allowed here. Best regards, Jerome > -----Message d'origine----- > De : news [mailto:[EMAIL PROTECTED] De la part de Patson > Envoyé : mardi 9 octobre 2007 13:05 > À : [email protected] > Objet : Issue when using Guard for POST and GET requests > > Hi all. I have started using restlet since last month and am > impressed with the > simplicity it offers. > > However, I bumped into a problem with using Guards earlier > and could not figure > out a good way to get around it. > > Basically I have one Restlet "TestRestlet" that handles both > GET and POST > requests. However, they have different URI patterns. > > For example, GET request would have pattern of /testGet/user/{userId} > and POST request would have pattern of /testPost > > Hence if I type http://localhost:8080/testGet/user/ABC, the > request would be > mapped to the GET handling of the TestRestlet and it would > return, say a form in > html format and the use can click submit on that form which points to > http://localhost:8080/testPost > > I have one single Guard: > > Guard testGuard= new TestGuard(getContext() > , ChallengeScheme.HTTP_BASIC > , "test Access Control"; //my TestGuard > class, same as Guard... > Restlet testRestlet = new TestRestlet(getContext()); > testGuard.setNext(testRestlet); > router.attach("/testGet/user/{userId}", testGuard); > router.attach("/testPost", testGuard); > > > Now, if I access /testGet/user/ABC, it would ask me for > authentication (401 > response), which is fine. After I input the user name and > password, it would > then return the html form which points to /testPost (which is > fine too). Now, if > I submit that form, I would get 401 response again...and the > web browser > obviously was confused (keep saying loading) and its stuck. > > My expectation is that the server should not give 401 status > code the 2nd time > (since it has already authenticated on the GET request and > they are sharing the > same Guard). The funny part is that if I change the pattern > "/testGet/user/{userId}" into just "/testGet" then all goes fine... > > I am not sure if its a bug or if its some stupid problem that > I made...can > anyone plz gimme some pointers plz? > > The Restlet jar I am using is the version 3.1 one. The server > is the Simple > server and Simple Framework. > > Many thanks in advance!!! >

