How do I add my own headers to a request wrapped by ClientResource
in Restlet? For example, I've read that you can use the following when working directly with Client
:
Form headers = (Form) request.getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
if (headers == null) {
headers = new Form();
request.getAttributes().put("org.restlet.http.headers", responseHeaders);
}
headers.add("X-Some-Header", "the value");
However, I am basically following the code provided in their tutorial and I do not know which member of ClientResource
should be accessed to set headers:
ClientResource clientResource = new ClientResource("http://webserviceurl");
MyClassResource classResource = clientResource.wrap(classResource.class);
MyClass class;
try { class = resource.retrieve(); } catch (Exception e) { System.out.println("fail."); }
What can I do to modify retrieve()
to add some headers?