okhttp

OkHttp bad requestBody

拥有回忆 提交于 2019-12-11 05:17:58
问题 I am using OkHTTP and I have some problems when I try to make a post request. Here is my code : client = new OkHttpClient(); formBody = new FormBody.Builder() .add(Constant.DIRECTION, Constant.OUT) .add(Constant.LIMIT, Constant.docs_limit) .add(Constant.IMPORTED, Constant.FALSE) .addEncoded("statuses[]", "4") request = new Request.Builder() .url(url) .addHeader(Constant.AUTH_TOKEN, sharedPreferences.getString(Constant.TOKEN, "")) .post(formBody) .build(); when I try to send "statuses[]", "4"

Call API on server that is signed using Self-Signed Certificate

时光怂恿深爱的人放手 提交于 2019-12-11 05:07:03
问题 I'm working on an Android application that call some API s over https . using retrofit2 and okhttp3 . During my development I use a self-signed certificate that I generate in server. I face a lot of problems in calling API s as I'm using a self-signed certificate, I solve them all but stuck on this exception SSLPeerUnverifiedException . Currently I had copy my certificate ServerCertificate.cer to Download directory in order to load it and add it to allowed KeyStore . I try a lot of solutions

java.io.IOException: stream was reset: REFUSED_STREAM on several devices

安稳与你 提交于 2019-12-11 04:59:32
问题 I'm using Retrofit 1.9 in my Android app. Server is on Django with Nginx, HTTPS with HTTP 2. Certificate is from WoSign, "A" score on SSL Labs. I'm testing on 3 devices: Nexus 4, Android 5.1.1 (official) Nexus 9, Android 7.0 (official) Samsung Galaxy S3, Android 4.4 (official) On SGS3 it works fine, but on Nexus 4 & 9 I'm getting the exception: java.io.IOException: stream was reset: REFUSED_STREAM at com.squareup.okhttp.internal.framed.FramedStream.getResponseHeaders(FramedStream.java:146) at

Okhttp not selecting http2 on Android 7.0

混江龙づ霸主 提交于 2019-12-11 04:39:53
问题 I am trying to make an HTTP request to the following domain (http2 enabled) on a device running on Android 7.0. The code i use is as follows: Request request = new Request.Builder() .url("https://http2.akamai.com/") .build(); response = okHttpClient.newCall(request).execute(); statusCode = response.code(); As I notice in the response object, the protocol used by okHttp is HTTP 1.1 The behavior of the okhttp client is random, at one time I was able to see the protocol as h2 but then repeating

okhttp3 maximum connection timeout

余生长醉 提交于 2019-12-11 03:33:17
问题 I need help with timeouts in okhttp3. I configured the maximum connect, read and write timeout to 4 minutes like that: OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(totalSeconds, TimeUnit.SECONDS) .writeTimeout(totalSeconds, TimeUnit.SECONDS) .readTimeout(totalSeconds, TimeUnit.SECONDS) .build(); totalSeconds = 240.000 but throws exception SocketTimeoutException in 2 minutes. Please someone have been in this situation? how can i solve it? Thanks in advance 来源: https:/

Retrofit java.net.ProtocolException: Expected ':status' header not present

故事扮演 提交于 2019-12-11 02:44:55
问题 Retrofit network calls fails with a Protocol Exception suddenly in a working app. The app was working till yesterday and today all the network calls fails. The calls works fine with HTTP and with some HTTPS except my production endpoint . It seems that app is not working only on my used https endpoint but working with other https endpoint, I tried. I fixed the problem this way - OkHttpClient client = new OkHttpClient(); client.setProtocols(Arrays.asList(Protocol.HTTP_1_1)); And And my problem

How to send image and text at the same time using retrofit

耗尽温柔 提交于 2019-12-10 22:19:02
问题 I want send this Postdata and imagefile at the same time using retrofit. PostData and Point public class PostData implements Serializable { @Expose private String text; @Expose private Point point; } public class Point implements Serializable { @Expose private double longitude; @Expose private double latitude; } PostApiService public interface PostApiService { @Multipart @POST("posts/") Call<ResponseBody> uploadFile (@Part MultipartBody.Part part, @Body PostData postData); } I get image uri

Does OkHttp send Authorization and other potentially sensitive headers on redirect?

ε祈祈猫儿з 提交于 2019-12-10 18:37:52
问题 I'm using OkHttp transitively through Apache NiFi. I'm attempting to determine how Authorization and other sensitive headers are handled on redirect. The only interaction that NiFi's InvokeHTTP processor has with OkHttp in regards to redirects is here, where it reads a processor property and sets the option on the OkHttpClientBuilder object: // Set whether to follow redirects okHttpClientBuilder.followRedirects(context.getProperty(PROP_FOLLOW_REDIRECTS).asBoolean()); Quickly searching through

Try-with-resources requires API level 19 (OkHttp)

孤街浪徒 提交于 2019-12-10 15:49:53
问题 I am trying to get web server response with OkHttp. My current minSdkVersion 15 . My code is @Override protected String doInBackground(String... strings) { GetDataFromUrl getData = new GetDataFromUrl(); String response = null; try { response = getData.run(URL); } catch (IOException e) { e.printStackTrace(); } return response; } And String run(String url) throws IOException { Request request = new Request.Builder() .url(url) .build(); try (Response response = client.newCall(request).execute())

MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US

泄露秘密 提交于 2019-12-10 14:25:15
问题 I am getting, Caused by java.lang.InternalError: java.util.MissingResourceException: Can't find bundle for base name sun.util.logging.resources.logging, locale en_US in my application from firebase crash report. Other details Manufacturer: HTC Model: HTC 10 Android API: 24 Here is the stack trace java.util.logging.Logger$1.run (Logger.java:1385) java.util.logging.Logger$1.run (Logger.java:1379) java.security.AccessController.doPrivileged (AccessController.java:41) java.util.logging.Logger