Skip to content

Commit

Permalink
Move basic enum types to common and use expect/actual for IOException (
Browse files Browse the repository at this point in the history
…#6966)

* Move basic enum types to common and use expect/actual for IOException

* Move basic enum types to common and use expect/actual for IOException

* Move basic enum types to common and use expect/actual for IOException

* Cleanup gradle
  • Loading branch information
yschimke committed Jan 3, 2022
1 parent b23158b commit c48f63b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
8 changes: 8 additions & 0 deletions okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ kotlin {
sourceSets {
commonMain {
kotlin.srcDir("$buildDir/generated/sources/kotlinTemplates")
dependencies {
api(Dependencies.okio)
}
}
commonTest {
dependencies {
implementation(Dependencies.kotlinTest)
implementation(Dependencies.kotlinTestAnnotations)
}
}
create("nonJvmMain") {
dependencies {
dependsOn(sourceSets.commonMain.get())
}
}

getByName("jvmMain") {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package okhttp3

import java.io.IOException
import kotlin.jvm.JvmStatic
import okio.IOException

/**
* Protocols that OkHttp implements for [ALPN][ietf_alpn] selection.
Expand Down
27 changes: 27 additions & 0 deletions okhttp/src/commonMain/kotlin/okhttp3/TlsVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2021 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

/**
* Versions of TLS that can be offered when negotiating a secure socket.
*/
expect enum class TlsVersion {
TLS_1_3, // 2016.
TLS_1_2, // 2008.
TLS_1_1, // 2006.
TLS_1_0, // 1999.
SSL_3_0; // 1996.
}
4 changes: 2 additions & 2 deletions okhttp/src/jvmMain/kotlin/okhttp3/TlsVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package okhttp3
* Versions of TLS that can be offered when negotiating a secure socket. See
* [javax.net.ssl.SSLSocket.setEnabledProtocols].
*/
enum class TlsVersion(
actual enum class TlsVersion(
@get:JvmName("javaName") val javaName: String
) {
TLS_1_3("TLSv1.3"), // 2016.
Expand All @@ -37,7 +37,7 @@ enum class TlsVersion(

companion object {
@JvmStatic
fun forJavaName(javaName: String): TlsVersion {
fun forJavaName(javaName: String): TlsVersion {
return when (javaName) {
"TLSv1.3" -> TLS_1_3
"TLSv1.2" -> TLS_1_2
Expand Down
24 changes: 24 additions & 0 deletions okhttp/src/nonJvmMain/kotlin/okhttp3/TlsVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2021 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

actual enum class TlsVersion {
TLS_1_3, // 2016.
TLS_1_2, // 2008.
TLS_1_1, // 2006.
TLS_1_0, // 1999.
SSL_3_0; // 1996.
}

0 comments on commit c48f63b

Please sign in to comment.