okhttp3

OkHttp connection leak log line even when OkHttp is not a dependency

南笙酒味 提交于 2021-02-05 06:10:52
问题 I keep seeing the following log line in Logcat while I use my app: 19098-19147/<package> W/OkHttpClient: A connection to <my server> was leaked. Did you forget to close a response body? I did some research on this bug and found that it can happen when you do things like forget to close a response body in an interceptor. I commented out all of interceptors to see if one of them was causing this issue, but I still saw the log line. I eventually commented out all uses of OkHttp and I still

Transfer Encoding chunked with okhttp only delivers full result

喜你入骨 提交于 2021-01-27 04:42:12
问题 I am trying to get some insights on a chunked endpoint and therefore planned to print what the server sends me chunk by chunk. I failed to do so so I wrote a test to see if OkHttp/Retrofit are working as I expect it. The following test should deliver some chunks to the console but all I get is the full response. I am a bit lost what I am missing to even make the MockWebServer of OkHttp3 sending me chunks. I found this retrofit issue entry but the answer is a bit ambiguous for me: Chunked

How can I more efficently download large files over http?

ε祈祈猫儿з 提交于 2021-01-24 08:01:22
问题 I'm trying to download large files (<1GB) in Kotlin since I already knew I'm using okhttp and pretty much followed just used the answer from this question. Except that I'm using Kotlin instead of java, so the syntax is slightly diffrent. val client = OkHttpClient() val request = Request.Builder().url(urlString).build() val response = client.newCall(request).execute() val is = response.body().byteStream() val input = BufferedInputStream(is) val output = FileOutputStream(file) val data =

How can I more efficently download large files over http?

旧街凉风 提交于 2021-01-24 08:01:07
问题 I'm trying to download large files (<1GB) in Kotlin since I already knew I'm using okhttp and pretty much followed just used the answer from this question. Except that I'm using Kotlin instead of java, so the syntax is slightly diffrent. val client = OkHttpClient() val request = Request.Builder().url(urlString).build() val response = client.newCall(request).execute() val is = response.body().byteStream() val input = BufferedInputStream(is) val output = FileOutputStream(file) val data =

Retrofit 2: How to set individual timeouts on specific requests?

自作多情 提交于 2021-01-21 03:37:19
问题 I have set a global timeout in my Retrofit adapter by doing OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS); retrofit = new Retrofit.Builder() .client(okHttpClient) .build(); Great! But I would like to set an specific timeout for certain requests E.g. public interface MyAPI { @GET() Call<Void> notImportant (@Url String url); @GET Call<Void> veryImportant(@Url String url); So veryImportant

Retrofit 2: How to set individual timeouts on specific requests?

会有一股神秘感。 提交于 2021-01-21 03:33:54
问题 I have set a global timeout in my Retrofit adapter by doing OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS); retrofit = new Retrofit.Builder() .client(okHttpClient) .build(); Great! But I would like to set an specific timeout for certain requests E.g. public interface MyAPI { @GET() Call<Void> notImportant (@Url String url); @GET Call<Void> veryImportant(@Url String url); So veryImportant

Retrofit 2: How to set individual timeouts on specific requests?

痴心易碎 提交于 2021-01-21 03:32:12
问题 I have set a global timeout in my Retrofit adapter by doing OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS); retrofit = new Retrofit.Builder() .client(okHttpClient) .build(); Great! But I would like to set an specific timeout for certain requests E.g. public interface MyAPI { @GET() Call<Void> notImportant (@Url String url); @GET Call<Void> veryImportant(@Url String url); So veryImportant