restlet

Restlet reuse InputStream

帅比萌擦擦* 提交于 2019-12-11 03:36:01
问题 Consider the next code. Filter: public class InputFilter extends Filter { @Override protected int beforeHandle(Request request, Response response) { int result = CONTINUE; InputStream inputStream = request.getEntity().getStream(); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, "UTF-8"); String theString = writer.toString(); JsonRepresentation jRep = new JsonRepresentation(theString); String token = jRep.getJsonObject().getString("token"); . . . return result; } }

Restlet: How can I retrieve DTO with setting custom MediaType?

故事扮演 提交于 2019-12-11 03:16:52
问题 How can I send GET request for entity with custom MediaType ? For example I want to retrieve MyUserDTO and set MediaType to application/user+yml . For now I have two separated actions. I can retrieve entity: resource.get(MyUserDTO.class); and can retrieve string: resource.get(new MediaType("application", "user+yml"); But how to combine them? Or maybe there is some trick to configure Restlet to teach him how to work with custom MediaTypes. 回答1: In fact, you have the right approach but you don

Can't get resource files in my template files (using Restlet and Freemarker)

戏子无情 提交于 2019-12-11 03:08:33
问题 I'm trying to develop a webapp with Restlet and I have a little problem for access to my /public/css/* and /public/js/*. I have messages like this in the console : INFO: 2012-03-10 23:52:59 127.0.0.1 - - 8182 GET /public/css/bootstrap-responsive.min.css - 404 439 0 0 http://localhost:8182 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/17.0.963.65 Chrome/17.0.963.65 Safari/535.11 http://localhost:8182/hello I currently only have a HelloWorld using

Camel Restlet maxThreads Component Option

谁都会走 提交于 2019-12-11 02:59:52
问题 I have a problem. The apache camel documentation states that for the camel-restlet component (starting from 2.10 version) is possible to define the max number of threads that will service requests (http://camel.apache.org/restlet.html). How can i specify this parameter? This is the route that I made from( "restlet:http://localhost:" + config.getEmergencyRESTPort() + "?restletMethods=post,get&restletUriPatterns=#emergencyUriTemplates&maxThreads=64").process( new EmergencyServerProcessor(config

HttpClient: disabling chunked encoding

浪尽此生 提交于 2019-12-11 02:40:27
问题 I am using the Apache Commons HttpClient along with Restlet to call a restful web service. Unfortunately, my server (based on Ruby on Rails) does not like the Transfer-Encoding: chunked that HttpClient is using by default. Is there any way to disable the usage of chunked encoding for POSTs from the client? 回答1: As said in Restlet mailing list, in Restlet version 2.1, you can set ClientResource#entityBuffering property to true to cache content in memory and prevent chunked encoding. 回答2: As a

RESTlet 2.1 can't get client certificate

无人久伴 提交于 2019-12-11 02:26:10
问题 I recently updated restlet to version 2.1 and I'm no longer able to get the client certificate. I'm using the new way to get client certificate List<Certificate> r = getRequest().getClientInfo().getCertificates(); I'm using CURL to send my authentication info curl -k -E admin.pem https://localhost:8111/profile -v Any idea why this doesn't work in restlet 2.1 ? 回答1: You should upgrade to version 2.2 which changed the internal HTTP connector and should restore this property. 来源: https:/

How to specify Restlet customer HTTP header with key as “Authorization”

百般思念 提交于 2019-12-11 01:59:08
问题 I am using Restlet2.3 to run REST API test automation. The new feature has a customer HTTP header to pass a token to the service. Form headers = (Form)resource.getRequestAttributes().get("org.restlet.http.headers"); if (headers == null) { headers = new Form(); resource.getRequestAttributes().put("org.restlet.http.headers", headers); } ... headers.add(key, value); The code works. Now, the customer HTTP header is defined as "Authorization". The above code seems not passing the header properly.

Swagger not working

为君一笑 提交于 2019-12-11 01:45:15
问题 I'm having a bit of trouble making Swagger display API docs using Restlet. What Swagger shows is just these stuff: And checking the api-docs it only shows this: I wonder what is wrong with my code: public class MyApplication extends SwaggerApplication { private static final String ROOT_URI = "/"; public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach(ROOT_URI, RootServerResource.class); router.attach(ROOT_URI + "ping", PingServerResource.class); router

Reading config files within Web-INF in RESTLET

故事扮演 提交于 2019-12-11 01:09:25
问题 I'm trying to read a config file placed inside the root path of WEB-INF. The application is using RESTLET framework. I read in the official RESTLET doc that its possible to read files via a WAR connector ("war:///WEB-INF/web.xml") using Context.getClientDispatcher(). However i was not able to figure out as to how this can be achieved. Kindly let me know about this or any other ways a file can be read using RESTLET 回答1: Found the solution for this. I had to access the ServletContext to get to

How can I enable GZIP compression of the JSON response entity on Reslet?

纵饮孤独 提交于 2019-12-10 22:58:14
问题 I have a Restlet application already working that accepts JSON and returns JSON entity as response. I'm trying to understand how I can compress the JSON entity that is returned in the response. I did not find any clear example on how to achieve it. I think I have to put somewhere on the router chain the Encoder/EncoderService classes, but I really don't understand where and how to use them. Could anybody help me? 回答1: After some testing, I got the answer. Creating a new filter like this