Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
can set no proxy to false
  • Loading branch information
A.Badakhshan committed Oct 25, 2023
1 parent ae16d8e commit 1107564
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ayannetworking/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.4.2"
versionName "1.5.0"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AyanApi(
var headers: HashMap<String, String> = HashMap(),
val stringParameters: Boolean = false,
val forceEndPoint: String? = null,
val setNoProxy: Boolean = true,
val hostName: String? = null,
val logItems: List<Int>? = null,
val feed: Array<Int>? = null,
Expand Down Expand Up @@ -82,6 +83,7 @@ class AyanApi(
fun aaa(
defaultBaseUrl: String,
timeout: Long,
setNoProxy: Boolean,
hostName: String? = null,
logItems: List<Int>? = null,
feed: Array<Int>?,
Expand All @@ -91,6 +93,7 @@ class AyanApi(
userAgent,
defaultBaseUrl,
timeout,
setNoProxy,
hostName,
logItems,
feed,
Expand Down Expand Up @@ -196,7 +199,7 @@ class AyanApi(
}
} catch (e: Exception) {
}
aaa(defaultBaseUrl, timeout, hostName, logItems, feed, gson).callApi(
aaa(defaultBaseUrl, timeout, setNoProxy, hostName, logItems, feed, gson).callApi(
finalUrl,
request,
headers
Expand All @@ -209,7 +212,7 @@ class AyanApi(
try {
wrappedPackage.reCallApi = {
ayanCallStatus.dispatchLoad()
aaa(defaultBaseUrl, timeout, hostName, logItems, feed, gson).callApi(
aaa(defaultBaseUrl, timeout, setNoProxy, hostName, logItems, feed, gson).callApi(
wrappedPackage.url,
wrappedPackage.request,
headers
Expand Down Expand Up @@ -337,7 +340,7 @@ class AyanApi(
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
wrappedPackage.reCallApi = {
ayanCallStatus.dispatchLoad()
aaa(defaultBaseUrl, timeout, hostName, logItems, feed, gson).callApi(
aaa(defaultBaseUrl, timeout, setNoProxy, hostName, logItems, feed, gson).callApi(
wrappedPackage.url,
wrappedPackage.request,
headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object RetrofitClient {
userAgent: String,
defaultBaseUrl: String,
timeout: Long = 20,
setNoProxy: Boolean,
hostName: String? = null,
logItems: List<Int>? = null,
feed: Array<Int>? = null,
Expand All @@ -35,13 +36,14 @@ object RetrofitClient {
else GsonConverterFactory.create(gson)
)
.baseUrl(defaultBaseUrl)
.client(getOkHttpInstance(userAgent, timeout, hostName, logItems, feed))
.client(getOkHttpInstance(userAgent, timeout, setNoProxy, hostName, logItems, feed))
.build()
.also { retrofit = it }

private fun getOkHttpInstance(
userAgent: String,
timeout: Long,
setNoProxy: Boolean,
hostName: String? = null,
logItems: List<Int>? = null,
feed: Array<Int>? = null
Expand All @@ -51,7 +53,8 @@ object RetrofitClient {
okHttpClientBuilder.connectTimeout(timeout, TimeUnit.SECONDS)
okHttpClientBuilder.readTimeout(timeout, TimeUnit.SECONDS)
okHttpClientBuilder.writeTimeout(timeout, TimeUnit.SECONDS)
okHttpClientBuilder.proxy(Proxy.NO_PROXY)
if (setNoProxy)
okHttpClientBuilder.proxy(Proxy.NO_PROXY)
okHttpClientBuilder.protocols(arrayListOf(Protocol.HTTP_2, Protocol.HTTP_1_1))
okHttpClientBuilder.addInterceptor {
val userAgentRequest = it.request()
Expand Down

0 comments on commit 1107564

Please sign in to comment.