I am trying to define my own logic of how is cache handled when it is full, because actual behavior is not wanted. I do not know if it is possible (I have not found any documentation on this topic), so I am asking here. When cache is full, Retrofit/OkHttp is removing cached responses based on their validity duration, prioritizing
Tag: okhttp
java.lang.NoSuchFieldError: Companion when using `influx-client-reactive` and `quarkus`
Error occurs when instantiating a client dependency is excluded from quarkus-bom otherwise (3.x.x) is forced and would cause at the same line. trace: Answer This issue led me to think that com.squareup.okio:okio might also play a role here. That Options.of is a call to method in that dependency and not Optional from java. That there is nothing strange here other
Sending data from android to esp8266
I have an arduino project, where i was able to set up an esp8266 as a webserver, and i am able to send data to it, eg. if i put “http://192.168.4.1/get?data=010” into the browser, it works perfectly. I want to send data using an android app, which pretty much means using the above mentioned url, just with different values for
OkHttp WebSocket RejectedExecutionException when try to restart
I have this client: And this methods for start and stop: Sometimes I want to restart the connection like this: But at start() I get this error: Answer The solution in my case was to create a new OkHttpClient and WebSocket every time when I want to restart.
Mocking nested retrofit api calls using MockWebServer
I am writing a junit test using okhttp3.mockwebserver for a retrofit2 rest api. The trimmed down api looks like this: The api is then injected to another class which delegates the calls thusly: I do the following in my test: Because the implementation of cancelOrder() calls api.cancelOrder() and then api.getOrders(), I added two mocked responses corresponding to each. However, looks
https proxy using okhttp3
I am using okhttp3 and trying to see how do I pass userId & pswd to authenticate with proxy server that accepts only HTTPS protocol. I already saw exmaple over SO & on other sites(link below) but they don’t have HTTPS protocol. https://botproxy.net/docs/how-to/okhttpclient-proxy-authentication-how-to/ Can anyone please tell me how to use HTTPS protocol to call proxy server? Answer It is
Could not transfer artifact com.squareup.okhttp3:mockwebserver:pom:4.9.1 from/to central (https://repo.maven.apache.org/maven2)
I have encountered a problem while importing the MockWebServer dependencies into my project Idea is showing 2 problems: Dependency ‘com.squareup.okhttp3:okhttp:4.9.1’ not found Dependency ‘com.squareup.okhttp3:mockwebserver:4.9.1’ not found And reload all maven projects results in a big “stacktrace” which generally says that it can’t resolve any of the dependencies. Running maven goal compile results in an error: Could not transfer artifact com.squareup.okhttp3:okhttp:pom:4.9.1
How to auto refresh data in android studio every second?
I am new to android studio, I am making an app that gets the json of a field in thingspeak, but I don’t know how can I make an auto refresh to the data I get every second. Can you please help me? Answer I found a solution finally, I placed the data request inside the following code and it
Update default Content-Type for multipart form-data request in Android
We are currently using okhttp3 and retrofit2 in Android to make an network api call of type POST with multipart/form-data, the api request and response are as shown below If you observe, the request header Content-Type has “multipart/form-data; boundary=xxxxxx-xxxx-xxx….” Following is the code I’m facing an issue with sending the customised request header Content-Type as “multipart/form-data; **charset=utf-8;** boundary=xxxxx-xxxxx-x…..” basically i
Exchange cookies between requests in OkHttp
I’m trying to scrape one website, and for that, I need to exchange the cookies and headers between all the requests. The question is the following: how can I achieve such behaviour in a smart way, not by resetting the cookies and headers manually between the Request and Response objects each time? Answer You’ll need a CookieJar. There’s an in-memory