Since no one seems to have responded to this problem I was hoping someone could shed some light on cookie setting. Similarly to adding my own header to all outgoing client requests I could instead set a cookie. My one requirement here is that I don't want to modify every outgoing request individually. In other words, the following code *won't *work...
request.getCookies().add("myCookie", "value"); Instead I need a solution where I set the cookie for the Client instance once and it is respected across all future connections and requests. Is this possible? Or am I really stuck having to add it to every outgoing request? Also please note it is *not* possible to set the cookie on the server side. On Mon, May 3, 2010 at 5:24 PM, Jean-Philippe Steinmetz < caskate...@gmail.com> wrote: > Hi Stephan, > > Thank you for the response. I've implemented a filter and created one while > setting the "next" property to be my client but I am not getting any calls > to the beforeHandle function. My code looks like the following. > > class MyFilter extends Filter > { > public MyFilter() { this(null); > public MyFilter(Context context) { this(context, null); } > public MyFilter(Context context, Restlet next) { super(context, next); > } > > public int beforeHandle(Request request, Response response) > { > System.out.println("HIT!"); > return CONTINUE; > } > } > > And my Spring configuration looks like this... > > <bean id="client" class="org.restlet.Client"> > <constructor-arg index="0"> > <bean class="org.restlet.Context"/> > </constructor-arg> > <constructor-arg index="1"> > <util:constant static-field="org.restlet.data.Protocol.HTTP"/> > </constructor-arg> > </bean> > <bean id="clientHelper" > class="com.noelios.restlet.ext.httpclient.HttpClientHelper"> > <constructor-arg ref="client"/> > </bean> > <bean id="myFilter" class="MyFilter"> > <property name="next" ref="client" /> > </bean> > > What am I missing? Thanks again. > > Jean-Philippe > > > On Sat, May 1, 2010 at 3:49 AM, Stephan Koops <stephan.ko...@web.de>wrote: > >> Hi Jean, >> >> the access is on both sides the same. That's an advantage of Restlet. >> To add the header for every request you could create a filter. It adds >> the header. Instead of send the request directly by the Client object >> you set the Client as next Restlet in the filter and your application >> sends all request via the filter. >> (I hope that's right ...) >> >> best regards >> Stephan >> >> Jean-Philippe Steinmetz schrieb: >> > Hi, >> > >> > I'm trying to add a custom HTTP header to outgoing requests when using >> > the restlet client API. Ideally i'm looking for some way to implement >> > a helper class that can inject my header into every request as they >> > are processed. However in looking through the documentation i'm not >> > really finding what i'm looking for. I see in the FAQ it's possible to >> > access headers but this seems to be from the server perspective. How >> > do I get access from a client perspective? >> > >> > Thanks in advance, >> > >> > Jean-Philippe Steinmetz >> >> ------------------------------------------------------ >> >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2600427 >> > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2603060