restlet

How to use CORS in Restlet 2.3.1?

心不动则不痛 提交于 2019-12-21 20:48:58
问题 I'm trying to set the 'Access-Control-Allow-Origin: *' header for the response. However, the header is not present. What am I doing wrong? public class JsonApplication extends Application { private static final String SERVER_URL = "http://localhost:8111"; public static void main(String[] args) throws Exception { Server testServer = new Server(Protocol.HTTP, 8111); JsonApplication jsonApplication = new JsonApplication(); CorsService corsService = new CorsService(); corsService

browsers send Options instead of Post after changing http header

夙愿已清 提交于 2019-12-21 02:56:07
问题 /*set the response header*/ Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers"); if (responseHeaders == null) { responseHeaders = new Form(); responseHeaders.add("Access-Control-Allow-Origin", "*"); responseHeaders.add("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE"); getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); } I added this in my restlet 2.0 code to allow for cross domain access, this does make the first

Streaming data from client with HTTP Post

吃可爱长大的小学妹 提交于 2019-12-19 15:43:01
问题 I would like to stream data from the client to the server. My application streams audio data to the server. I do not know how long the audio will be when I begin streaming it. I want to reduce latency by transmitting the data as it is being recorded. Once all the data has been uploaded, then I will process it. So, what I would like is a HTTP POST where the body is streamed. At the client, the POST would be sent as the data is available. At the server end, I would like it to arrive like a

Restlet POST using JSON

醉酒当歌 提交于 2019-12-17 22:38:18
问题 How do I implement Restlet function which accepts JSON post? And how do I test this using curl? Thanks 回答1: With Restlet 2, you can either: test the entity media-type compatibility in @Post acceptRepresentation(Representation entity) : @Post public Representation acceptRepresentation(Representation entity) throws ResourceException { if (entity.getMediaType().isCompatible(MediaType.APPLICATION_JSON)) { // ... } // ... } or use @Post with one or two parameters: @Post("json") Representation

How do I interact with OData from Java?

我怕爱的太早我们不能终老 提交于 2019-12-17 18:16:48
问题 OData is Microsoft's repackaging of its Astoria (now WCF Data Services) RESTful query/update protocol. If I want to use Java to create an OData compatible data source, how do I do that? Similarly, if I want to consume an OData data source from Java, how do I do that? http://www.odata.org/ Partial answer below. The OData website suggests that Restlet supports OData. Restlet's API documentation mentions the org.restlet.ext.odata package. www.restlet.org/ www.restlet.org/documentation/snapshot

Is it ok by REST to return content after POST?

*爱你&永不变心* 提交于 2019-12-17 10:13:07
问题 I am using RESTlet and I have created a resource. I handle POST by overriding acceptRepresentation method. The client should send me some data, then I store it to DB, set response to 201 (SUCCESS_CREATED) and I need to return some data to the client, but return type of acceptRepresentation is void . In my case, I need to return some identificator so that client can access that resource. For example, if I had a resource with URL /resource and the client sends POST request I add a new row in DB

Android RESTLet SSL Null Pointer

淺唱寂寞╮ 提交于 2019-12-13 06:07:42
问题 I've been trying how to solve my problem for days but I didn't succeded. I'm just tyring to perform RESTlet HTTPS request. The code is quiet simple as I've only one acrivity: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); System.setProperty("java.net.preferIPv6Addresses", "false"); Engine.getInstance().getRegisteredClients().clear(); Engine.getInstance().getRegisteredClients().add(new HttpsClientHelper

Java: Binary File Upload using Restlet + Apache Commons FileUpload

浪子不回头ぞ 提交于 2019-12-13 05:42:35
问题 I have a REST API with Restlet 2.3 and need to implement a file-uploading functionality to it. The problem is that, when someone uploads a file using a POST (with a multipart/form-data Content-Type), the file reaches the server with another encoding. To test this, I printed the contents of the original file in a Unix Terminal and then printed it again before parsing the requet with Apache Commons FileUpload (with almost the same code of this example http://restlet.com/technical-resources

JSON Representation of a HTTP 400 for Restlet Client

…衆ロ難τιáo~ 提交于 2019-12-13 05:19:19
问题 I am struggling to access a JSON Representation of a Restlet Client Response when a 400 is expected. Any 400 response returns as an exception. I cannot get the JSON from an exception. Any ideas? Code: public def run(Object testCaseData) { ClientResource clientResource = RestAPIUtils.setClientResource(GroovyUtils.getDataValue(testCaseData, 'command').toString(), partnerAPICredential) def JSONData = JSONUtils.createJSONObject(testCaseData) Representation representation = RestAPIUtils

Is there a way to make Restlet Swagger extension limit the API it shows?

匆匆过客 提交于 2019-12-13 03:38:55
问题 Is there a way to make Restlet Swagger extension limit the API it shows? There are paths in the API we have that should not be explosed (just yet), what is the strategy to make sure that at least only specific org.restlet.routing.Router will be exposed? As we have many Router s in the Application. 回答1: This isn't possible out of the box. The easier way to do that is IMO to patch the extension org.restlet.extension.swagger : Update the method getSwagger of the class SwaggerSpecificationRestlet