-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Platform into a new plugin module
- Loading branch information
Showing
9 changed files
with
47 additions
and
18 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
9 changes: 0 additions & 9 deletions
9
ktor-client/ktor-client-cio/nix/src/io/ktor/client/engine/cio/Platform.kt
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
ktor-client/ktor-client-plugins/ktor-client-platform/api/ktor-client-platform.api
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 @@ | ||
public final class io/ktor/client/plugins/platform/PlatformingKt { | ||
public static final fun getPlatforming ()Lio/ktor/client/plugins/api/ClientPlugin; | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
ktor-client/ktor-client-plugins/ktor-client-platform/build.gradle.kts
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,7 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
description = "Ktor client platform support" | ||
|
||
useJdkVersionForJvmTests(11) |
4 changes: 2 additions & 2 deletions
4
...src/io/ktor/client/engine/cio/Platform.kt → ...or-client-platform/common/src/Platform.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
21 changes: 21 additions & 0 deletions
21
ktor-client/ktor-client-plugins/ktor-client-platform/common/src/Platforming.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,21 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package io.ktor.client.plugins.platform | ||
|
||
import io.ktor.client.plugins.api.ClientPlugin | ||
import io.ktor.client.plugins.api.createClientPlugin | ||
import io.ktor.client.request.host | ||
import io.ktor.utils.io.errors.UnknownServiceException | ||
|
||
public val Platforming: ClientPlugin<Any> = createClientPlugin("Platforming", ::Any) { | ||
onRequest { request, _ -> | ||
val host = request.host | ||
if (!Platform.isCleartextTrafficPermitted(host)) { | ||
throw UnknownServiceException( | ||
"CLEARTEXT communication to $host not permitted by network security policy" | ||
) | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...src/io/ktor/client/engine/cio/Platform.kt → .../ktor-client-platform/jvm/src/Platform.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
10 changes: 10 additions & 0 deletions
10
ktor-client/ktor-client-plugins/ktor-client-platform/nonJvm/src/Platform.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,10 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package io.ktor.client.plugins.platform | ||
|
||
internal actual object Platform { | ||
|
||
fun isCleartextTrafficPermitted(hostname: String): Boolean = false | ||
} |
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