-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from viethua99/issue/ios-network
[KMP] Fix iOS Ktor network issues
- Loading branch information
Showing
13 changed files
with
71 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
composeApp/src/androidMain/kotlin/com/vproject/stablediffusion/di/KoinAndroid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
package com.vproject.stablediffusion.di | ||
|
||
import com.vproject.stablediffusion.util.TestUtil | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.okhttp.OkHttp | ||
import io.ktor.client.plugins.HttpTimeout | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import org.koin.dsl.module | ||
|
||
actual fun platformModule() = module { | ||
single { TestUtil(get()) } | ||
|
||
single { | ||
HttpClient(OkHttp) { | ||
install(ContentNegotiation) { | ||
json(Json { ignoreUnknownKeys = true }) | ||
} | ||
|
||
install(HttpTimeout) { | ||
requestTimeoutMillis = 120000 | ||
connectTimeoutMillis = 120000 | ||
socketTimeoutMillis = 120000 | ||
} | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
composeApp/src/androidMain/kotlin/com/vproject/stablediffusion/network/HttpClientAndroid.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.vproject.stablediffusion.network | ||
|
||
class HttpClientAndroid { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
composeApp/src/desktopMain/kotlin/com/vproject/stablediffusion/di/KoinDesktop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
package com.vproject.stablediffusion.di | ||
|
||
import com.vproject.stablediffusion.util.TestUtil | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.plugins.HttpTimeout | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import org.koin.dsl.module | ||
|
||
actual fun platformModule() = module { | ||
single { TestUtil() } | ||
|
||
single { | ||
HttpClient { | ||
install(ContentNegotiation) { | ||
json( Json { ignoreUnknownKeys = true }) | ||
} | ||
|
||
install(HttpTimeout) { | ||
requestTimeoutMillis = 120000 | ||
connectTimeoutMillis = 120000 | ||
socketTimeoutMillis = 120000 | ||
} | ||
} | ||
} | ||
} |
22 changes: 21 additions & 1 deletion
22
composeApp/src/iosMain/kotlin/com/vproject/stablediffusion/di/KoiniOS.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
package com.vproject.stablediffusion.di | ||
|
||
import com.vproject.stablediffusion.util.TestUtil | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.engine.darwin.Darwin | ||
import io.ktor.client.plugins.HttpTimeout | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import org.koin.dsl.module | ||
|
||
actual fun platformModule() = module { | ||
single { TestUtil() } | ||
single { TestUtil() } | ||
|
||
single { | ||
HttpClient(Darwin) { | ||
install(ContentNegotiation) { | ||
json(Json { ignoreUnknownKeys = true }) | ||
} | ||
|
||
install(HttpTimeout) { | ||
requestTimeoutMillis = 120000 | ||
connectTimeoutMillis = 120000 | ||
socketTimeoutMillis = 120000 | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters