Which launched the HTTPS client for use on Android?

I am new to restlet and trying to figure out which HTTPS client option I should use with Android. Which HTTPS client option is the most reliable and stable for Android? I am using restlet 2.1rc4 (and 2.1.0) and android 2.2. Unfortunately, changing the version for Android is not an option for me.

I think the possibilities are:

  • Apache HttpClient (org.restlet.ext.httpclient)
  • .net client (org.restlet.ext.net)
  • Restlet Internal Client

I had some success with org.restlet.ext.net, it works most of the time, but I get various exceptions with "Communication error (1001) with messages like" broken pipe ", as well as many cases immediately return from a client request with status "null (-1)" without sending a request to the server. Perhaps this is caused by errors in the old android that we use, but I'm not sure.

I tried using the Apache client, but I cannot get HTTPS to work at all because it gives this exception: java.lang.IllegalStateException: Scheme 'https' is not registered. The same code works on Windows with the Jave SE version org.restlet.ext.net.jar, but when I use the Android version of the same jar file, it says https is not registered. I thought the Apache client supports HTTPS on Android, but it does not work for me.

I also tried the internal client, but this also does not work. I get the same error 1001 as Android RESTLet SSL Null Pointer . I tried this with restlet 2.1.0 and android 2.2.

My source code is mostly similar to this (showing an attempt to use the Apache client):

context = new org.restlet.Context(); Engine.getInstance().getRegisteredConverters().add(new JacksonConverter()); Engine.getInstance().getRegisteredClients().add(new org.restlet.ext.httpclient.HttpClientHelper(null)); client = new org.restlet.Client(context, org.restlet.data.Protocol.HTTPS); context.setClientDispatcher(client); ClientResource resource = new ClientResource(context, url); resource.setEntityBuffering(true); PojoResult result = resource.post(new PojoRequest, PojoResult.class); 
+4
source share
1 answer

The new version of Restlet Framework version 2.2 has changed its internal HTTP / HTTPS client based on HttpURLConnection (previously in the extension org.restlet.ext.net). It is more stable and lightweight in terms of size for org.restlet.jar.

0
source

Source: https://habr.com/ru/post/1441007/


All Articles