I know that Retrofit uses OkHttp internally. But, I see that some developers have provided an approach like below
return new Retrofit.Builder() .baseUrl(BuildConfig.API_ENDPOINT) .client(getClient()) // we can add OkHttpClient client there
So, can someone clarify why this is necessary?
I heard that this can be useful for testing when we can use a custom Interceptor while mixing HTTP requests.
OkHttp , OkHttpClient. , OkHttp. , JavaDoc. , , , -, DNS, ( ), -, ( HTTPS, HTTP ) .
OkHttpClient
EDIT: , , API API REST. , , VPN - , , . , , , . Spotify YouTube. WiFi, (, UDP). 3G, TCP .
OkHttp Retrofit, Retrofit .client(new OkHttpClient()), , , . , .
OkHttp
Retrofit
.client(new OkHttpClient())
, " " .
Edit
, .
. OkHttp .
OkHttpClient. -, - .
OkHttpClient for the prod product should work as expected. OkHttpClient for artificial taste should use a custom Interceptor. This custom Interceptor can be used to analyze server requests and apply your predefined responses from your resource folder. This is a pretty elegant way to mock a server.
Source: https://habr.com/ru/post/1684750/More articles:How can I carry out special orders in BlueSnap? - paymentDatatrigger after insertion - paste into a table ON ANOTHER SERVER - sqlОткройте файл с правами администратора, но перед тем, как читать его, отпустите привилегии? - cCQRS: updating a read model without using events - c #data cutoff string. after duplication - rмножественные серверы аутентификации настроены и поэтому должны предоставлять аргумент "backend" или устанавливать атрибут "backend" для пользователя - pythonInvoke-WebRequest fails for large file - powershellHow to stop the text shadow applied to the text design? - htmlC # Predicate builder using AND with OR - c #Why isn't "default export" recommended in Angular? - angularAll Articles