1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-08 23:42:08 +03:00

Do IDNA mapping on Kotlin/JS (#7800)

This commit is contained in:
Jesse Wilson
2023-05-05 21:22:01 -04:00
committed by GitHub
parent 7bacd2e62d
commit cfaefe00c9
11 changed files with 173 additions and 41 deletions

View File

@@ -7,8 +7,23 @@ kotlin {
jvm {
withJava()
}
if (kmpJsEnabled) {
js(IR) {
nodejs()
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(libs.squareup.okio)
}
}
val jsMain by getting {
dependencies {
implementation(libs.squareup.okio.nodefilesystem)
}
}
val jvmMain by getting {
dependencies {
api(projects.okhttp)

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2023 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3
import okio.FileSystem
import okio.Path
import okio.Path.Companion.toPath
val okHttpRoot: Path
get() = getEnv("OKHTTP_ROOT")!!.toPath()
expect val SYSTEM_FILE_SYSTEM: FileSystem
expect fun getEnv(name: String): String?
expect val isJvm: Boolean

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2023 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3
import okio.FileSystem
import okio.NodeJsFileSystem
actual fun getEnv(name: String) = js("globalThis.process.env[name]") as String?
actual val SYSTEM_FILE_SYSTEM: FileSystem = NodeJsFileSystem
actual val isJvm = false

View File

@@ -22,6 +22,7 @@ import java.net.UnknownHostException
import java.util.Arrays
import okhttp3.internal.http2.Header
import okio.Buffer
import okio.FileSystem
import org.junit.jupiter.api.Assumptions.assumeFalse
import org.junit.jupiter.api.Assumptions.assumeTrue
@@ -122,3 +123,9 @@ object TestUtil {
block(suppressed.toList())
}
}
actual fun getEnv(name: String) = System.getenv(name)
actual val SYSTEM_FILE_SYSTEM = FileSystem.SYSTEM
actual val isJvm = true