Hi,
I used a clientResource (2.06), set the client info and wrap to my
interface....
My interface uses an @Get("json") annotation.
See:
final ClientResource cr = new
ClientResource("http://localhost:8080/app/Tester");
final ClientInfo ci = cr.getClientInfo();
ci.setAgent("Test-Client 1.0");
final TestingResource resource = cr.wrap(TestingResource.class);
resource.httpGet();
Now, from the trace output, the User-Agent is reset to Restlet default
value... ?
// Output traces
// GET /app/Tester HTTP/1.1
// Date: Tue, 10 May 2011 18:51:47 GMT
// Accept: application/json
// Host: localhost:8080
// User-Agent: Restlet-Framework/2.0.6
// Content-Length: 0
I saw in the wrap method that code:
if (responseVariants != null) {
request.setClientInfo(new ClientInfo(responseVariants));
}
I think it should be something like this:
if (responseVariants != null) {
List<Preference<MediaType>> acceptedMediaTypes =
request.getClientInfo().getAcceptedMediaTypes();
for (Variant variant : responseVariants) {
acceptedMediaTypes.add(new
Preference<MediaType>(variant.getMediaType()));
}
}
What do you think?
Else I don't know how to set my User-Agent header.
Nitram
--
View this message in context:
http://restlet-discuss.1400322.n2.nabble.com/ClientResource-wrap-interface-and-ClientInfo-tp6353079p6353079.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2734467