okhttp3

OkHttpClient throws exception after upgrading to OkHttp3

本小妞迷上赌 提交于 2020-01-28 17:40:23
问题 I'm using following lines of code to add a default header to all of my requests sent using Retrofit2: private static OkHttpClient defaultHttpClient = new OkHttpClient(); static { defaultHttpClient.networkInterceptors().add(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request().newBuilder() .addHeader("Accept", "Application/JSON").build(); return chain.proceed(request); } }); } After upgrading retrofit to beta-3 version, I

OkHttpClient throws exception after upgrading to OkHttp3

人盡茶涼 提交于 2020-01-28 17:40:15
问题 I'm using following lines of code to add a default header to all of my requests sent using Retrofit2: private static OkHttpClient defaultHttpClient = new OkHttpClient(); static { defaultHttpClient.networkInterceptors().add(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request().newBuilder() .addHeader("Accept", "Application/JSON").build(); return chain.proceed(request); } }); } After upgrading retrofit to beta-3 version, I

Exception in thread “main” java.lang.NoClassDefFoundError: okhttp3/ConnectionPool with Selenium and Java

被刻印的时光 ゝ 提交于 2020-01-24 23:40:11
问题 i have a simple Selenium Test Code: public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/home/chromedriver"); WebDriver driver= new ChromeDriver(); driver.get("http://google.com"); } And i get this Error: Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool | Caused by: java.lang.ClassNotFoundException: okhttp3.ConnectionPool I think the jars and Dependency are ok but i still get this Error 回答1: please check of this jars files

androidx.paging.PagedStorage.init is giving error when proguard is enabled

梦想的初衷 提交于 2020-01-23 19:01:25
问题 I'm using retrofit with okhttp and migrated to AndroidX, When I make a signed app that obfuscated with proguard it crashes and gives an error,but in debug mode when proguard is not enabled it's working good. and I disabled proguard just for testing and made a signed APK it's working this way too. so I'm sure the crash is caused by Proguard. And I did some search on google they all say that I have to add proguard rules for both OKHTTP and Retrofit I did add them too but it still crashes. The

Adding decodeSlash using Feign @RequestLine

瘦欲@ 提交于 2020-01-15 15:56:49
问题 I am currently using a YAML file to generate the models and the API clients using the swagger plugin and I am using Feign OkHttpClient to make requests to the API, the problem here is the client encodes the URL but ignores the Slash(es) with this the API call fails. Is there a way to add decodeSlash parameter in the client? Or can this be achieved using an interceptor? Here is the sample path param where I am running into this issue. QgKuK2DU/0%3D where as it should be QgKuK2DU%2F0%3D 回答1:

CompositeDisposable.clear causes OkHttp to throw java.lang.IllegalStateException: Unbalanced enter/exit

可紊 提交于 2020-01-11 10:08:06
问题 So I have a simple http request using OkHttp. I do this with RxJava on Android. I add this RxJava call to a CompositeDisposable that I then clear on onStop . For some reason that is triggering this exception below. I'm a little unsure about how to fix it. Caused by java.lang.IllegalStateException: Unbalanced enter/exit at okio.AsyncTimeout.enter(AsyncTimeout.java:73) at okio.AsyncTimeout$2.read(AsyncTimeout.java:235) at okio.RealBufferedSource.read(RealBufferedSource.java:47) at okhttp3

okhttp 3 very slow

我与影子孤独终老i 提交于 2020-01-05 07:01:53
问题 I try to get json from a server, I use https on the server and every http request will go to the https version. I get the data and the data that I send works to but it takes up to 45 sec to get a response back. The same code was faster with the build in http handler of android. How can I speed up the request? try { OkHttpClient client = new OkHttpClient(); FormBody.Builder formBuilder = new FormBody.Builder().add("key", "2285"); //formBuilder.add("phone", "000000"); RequestBody formBody =

OkHttp how to set maximum connection pool size (not max idle connections)

点点圈 提交于 2020-01-03 08:53:18
问题 In OkHttp I cannot find a way to set a hard maximum connection pool size. From the documentation https://square.github.io/okhttp/3.x/okhttp/okhttp3/ConnectionPool.html it is clear that you can set a maximum idle connections, but not an overall max. That means that with high load it can grow beyond any limit. Is there a way to maximize the pool? If not, why not? 回答1: Connections are either active and held by a particular in-flight call, or idle and in the pool. Limit the total number of

OkHttp how to set maximum connection pool size (not max idle connections)

浪尽此生 提交于 2020-01-03 08:53:09
问题 In OkHttp I cannot find a way to set a hard maximum connection pool size. From the documentation https://square.github.io/okhttp/3.x/okhttp/okhttp3/ConnectionPool.html it is clear that you can set a maximum idle connections, but not an overall max. That means that with high load it can grow beyond any limit. Is there a way to maximize the pool? If not, why not? 回答1: Connections are either active and held by a particular in-flight call, or idle and in the pool. Limit the total number of

OKHTTP newCall() hangs when calling restAPI

风流意气都作罢 提交于 2020-01-02 11:18:51
问题 Trying to post to a restAPI using JAVA OKHttp. My code looks as follows: try { loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); client = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .addInterceptor(loggingInterceptor) .build(); MediaType mediaType = MediaType.parse("app.lication/json"); RequestBody body = RequestBody.create(mediaType, FileUtils.readFileToString(file)); Request request = new Request.Builder()