Skip to content

Commit

Permalink
Fix Foso#372 Crash with Xiaomi on create Ktorfit.Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Перевалов Данил committed Jul 10, 2023
1 parent b25fcfc commit 1e59ec7
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class Ktorfit private constructor(
*/
public class Builder {
private var _baseUrl: String = ""
private var _httpClient = HttpClient()
private var _httpClient: HttpClient? = null
private var _responseConverter: MutableSet<ResponseConverter> = mutableSetOf()
private var _suspendResponseConverter: MutableSet<SuspendResponseConverter> = mutableSetOf()
private var _requestConverter: MutableSet<RequestConverter> = mutableSetOf()
Expand Down Expand Up @@ -160,7 +160,7 @@ public class Ktorfit private constructor(
* Client-Builder that will be used for every request with object
*/
public fun httpClient(config: HttpClientConfig<*>.() -> Unit): Builder = apply {
this._httpClient = HttpClient(this._httpClient.engine, config)
this._httpClient = HttpClient(config)
}

/**
Expand Down Expand Up @@ -219,7 +219,7 @@ public class Ktorfit private constructor(
public fun build(): Ktorfit {
return Ktorfit(
baseUrl = _baseUrl,
httpClient = _httpClient,
httpClient = _httpClient ?: HttpClient(),
responseConverters = _responseConverter,
suspendResponseConverters = _suspendResponseConverter,
requestConverters = _requestConverter,
Expand Down

0 comments on commit 1e59ec7

Please sign in to comment.