okio

why can I only read 2048 bytes at a time from an okhttp.Response InputStream?

天涯浪子 提交于 2020-04-10 18:05:26
问题 I am downloading a file using an OkHttp GET request: import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; ... OkHttpClient okClient = new OkHttpClient(); Request request = Request.Builder().url(url).get(); Response response = okClient.newCall(request).execute(); I read from the response body and decorating it with a BufferedInputStream , with a buffer size of 4096: BufferedInputStream in = new BufferedInputStream(response.body()

Spark and Influx: OKIO conflict

我怕爱的太早我们不能终老 提交于 2020-01-14 01:56:09
问题 I'm running a job on Spark Yarn and trying to emit messages to Influx DB but I'm crashing on an okio conflict: 22:17:54 ERROR ApplicationMaster - User class threw exception: java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String; java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String; at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212) at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java

Handling Authentication in Okhttp

本秂侑毒 提交于 2020-01-12 01:58:33
问题 I'm using OkHttp 2.3 with basic authentication requests, according to OKHttp docs, it automatically retries unauthenticated requests, but whenever I provide invalid credentials, the request takes too much time and I get this exception in the end: java.net.ProtocolException: Too many follow-up requests: 21 How can I prevent OkHttp from automatically retrying unauthenticated requests, and return 401 Unauthorized instead? 回答1: protected Authenticator getBasicAuth(final String username, final

Downloading files using OkHttp, Okio and RxJava

牧云@^-^@ 提交于 2020-01-01 19:48:21
问题 I'm trying to download files using OkHttp and writing to disk with Okio. Also I've created an rx observable for this process. It is working, however it is noticeably slower than what I had previously used (Koush's Ion library). Here's how I create the observable: public Observable<FilesWrapper> download(List<Thing> things) { return Observable.from(things) .map(thing -> { File file = new File(getExternalCacheDir() + File.separator + thing.getName()); if (!file.exists()) { Request request = new

kotlin/TypeCastException when trying to create OkHttpClient object

与世无争的帅哥 提交于 2019-12-21 07:55:52
问题 When i try to create a new OkHttpClient object an Exception get thrown I'm using OkHttp 3.11.0 and OkIO 2.0.0-RC1. Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/TypeCastException at okhttp3.ResponseBody.create(ResponseBody.java:210) at okhttp3.internal.Util.(Util.java:60) at okhttp3.OkHttpClient.(OkHttpClient.java:123) at p12.Main.main(Main.java:8) Caused by: java.lang.ClassNotFoundException: kotlin.TypeCastException at java.net.URLClassLoader.findClass(URLClassLoader.java

Download progress with RxJava, OkHttp and Okio in Android

丶灬走出姿态 提交于 2019-12-20 08:49:38
问题 In our app I download an image file with this code. I need to show download progress( downloaded bytes in percentage ) on UI. How I can get download progress in this code? I searched for solution, but still can't manage to do it on my own. Observable<String> downloadObservable = Observable.create( sub -> { Request request = new Request.Builder() .url(media.getMediaUrl()) .build(); Response response = null; try { response = http_client.newCall(request).execute(); if (response.isSuccessful()) {

Okhttp NoClassDefFoundError

烂漫一生 提交于 2019-12-12 10:58:19
问题 I am using OkHttp 2.0.0 jar in my android application on eclipse. As OkHttp is now dependent on Okio library, I also added Okio 1.0.0 jar in my project.The project compiles fine with no compilation errors but when I run on my android device, it gives me this NoClassDefFoundError all relating to the OkHttp library classes. I have placed all the jars in my libs folder of the project and added them to my build path and also tried checking them in the Export and Order Tab, but still it is not

Android-Studio-1.2.RC Proguard warnings on Square's Okio library reference

放肆的年华 提交于 2019-12-06 22:40:13
问题 WIth Android Studio: 1.2.RC I enabled proguard in .gradle: ``` minifyEnabled=true and added these rules to my proguard-rules.pro: -dontwarn com.squareup.** -dontwarn okio.** and added these lint rules to my .gradle file: warningsAsErrors false abortOnError false disable 'InvalidPackage' ``` But I still get these warning when I try to run the app in debug mode: ``` Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning: okio.Okio:

Spark and Influx: OKIO conflict

末鹿安然 提交于 2019-12-06 07:34:49
I'm running a job on Spark Yarn and trying to emit messages to Influx DB but I'm crashing on an okio conflict: 22:17:54 ERROR ApplicationMaster - User class threw exception: java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String; java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String; at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:212) at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) Here's my dependencies: val cdhVersion = "cdh5.12.2" val sparkVersion = "2.2.0.cloudera2" val

Android-Studio-1.2.RC Proguard warnings on Square's Okio library reference

試著忘記壹切 提交于 2019-12-05 03:31:59
WIth Android Studio: 1.2.RC I enabled proguard in .gradle: ``` minifyEnabled=true and added these rules to my proguard-rules.pro: -dontwarn com.squareup.** -dontwarn okio.** and added these lint rules to my .gradle file: warningsAsErrors false abortOnError false disable 'InvalidPackage' ``` But I still get these warning when I try to run the app in debug mode: ``` Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement Warning: okio.Okio: can't find referenced class java.nio.file.Files Warning: okio.Okio: can't find referenced class java