mirror of
https://github.com/square/okhttp.git
synced 2025-07-31 05:04:26 +03:00
Downgrade to kotlin apiVersion 1.4 (#7267)
* Test against kotlin 1.4 * Compile down to Kotlin 1.4 * Fix to use the invariant locale for lowercase * Fix to use the invariant locale for lowercase
This commit is contained in:
@ -113,10 +113,12 @@ subprojects {
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
apiVersion = "1.4"
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xjvm-default=compatibility",
|
||||
"-Xopt-in=kotlin.RequiresOptIn"
|
||||
"-opt-in=kotlin.RequiresOptIn"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ import okhttp3.internal.http2.Header
|
||||
import okhttp3.internal.http2.Http2Connection
|
||||
import okhttp3.internal.http2.Http2Stream
|
||||
import okhttp3.internal.immutableListOf
|
||||
import okhttp3.internal.lowercase
|
||||
import okhttp3.internal.platform.Platform
|
||||
import okhttp3.internal.threadFactory
|
||||
import okhttp3.internal.toImmutableList
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalCoroutinesApi::class)
|
||||
@file:OptIn(ExperimentalCoroutinesApi::class, ExperimentalTime::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
@ -39,6 +39,7 @@ import org.junit.jupiter.api.fail
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
@ExtendWith(MockWebServerExtension::class)
|
||||
class SuspendCallTest(
|
||||
|
@ -16,6 +16,7 @@
|
||||
package okhttp3.sse.internal
|
||||
|
||||
import java.io.IOException
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.toLongOrDefault
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
|
@ -17,6 +17,7 @@ package okhttp3.tls.internal.der
|
||||
|
||||
import java.math.BigInteger
|
||||
import java.net.ProtocolException
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
import okio.ByteString
|
||||
|
@ -16,6 +16,7 @@
|
||||
package okhttp3.tls.internal.der
|
||||
|
||||
import java.math.BigInteger
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.BufferedSink
|
||||
import okio.ByteString
|
||||
|
@ -13,9 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
/**
|
||||
* A Cache-Control header with cache directives from a server or client. These directives set policy
|
||||
|
@ -13,9 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3.internal
|
||||
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.toDuration
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Headers
|
||||
|
@ -394,3 +394,17 @@ internal fun <T> interleave(a: Iterable<T>, b: Iterable<T>): List<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
inline val Char.code
|
||||
get() = this.toInt()
|
||||
|
||||
expect inline fun String.lowercase(): String
|
||||
|
||||
expect inline fun String.uppercase(): String
|
||||
|
||||
inline fun <E> buildList(builderAction: MutableList<E>.() -> Unit): List<E> {
|
||||
return mutableListOf<E>().apply {
|
||||
builderAction()
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
@ -21,6 +24,7 @@ import assertk.assertions.isFalse
|
||||
import assertk.assertions.isTrue
|
||||
import kotlin.test.Test
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
class CacheControlTest {
|
||||
@Test
|
||||
|
@ -20,6 +20,7 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.internal.uppercase
|
||||
|
||||
/**
|
||||
* Test MediaType API and parsing.
|
||||
|
@ -31,6 +31,7 @@ import okhttp3.internal.cache.CacheRequest
|
||||
import okhttp3.internal.cache.CacheStrategy
|
||||
import okhttp3.internal.cache.DiskLruCache
|
||||
import okhttp3.internal.closeQuietly
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.concurrent.TaskRunner
|
||||
import okhttp3.internal.http.HttpMethod
|
||||
import okhttp3.internal.http.StatusLine
|
||||
|
@ -13,10 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
import okhttp3.internal.commonBuild
|
||||
import okhttp3.internal.commonClampToInt
|
||||
import okhttp3.internal.commonForceCache
|
||||
|
@ -23,6 +23,7 @@ import kotlin.text.Charsets.ISO_8859_1
|
||||
import okhttp3.internal.commonEquals
|
||||
import okhttp3.internal.commonHashCode
|
||||
import okhttp3.internal.commonToString
|
||||
import okhttp3.internal.lowercase
|
||||
|
||||
actual class Challenge actual constructor(
|
||||
@get:JvmName("scheme") actual val scheme: String,
|
||||
|
@ -23,10 +23,12 @@ import java.util.Locale
|
||||
import java.util.regex.Pattern
|
||||
import okhttp3.internal.UTC
|
||||
import okhttp3.internal.canParseAsIpAddress
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.delimiterOffset
|
||||
import okhttp3.internal.http.MAX_DATE
|
||||
import okhttp3.internal.http.toHttpDateString
|
||||
import okhttp3.internal.indexOfControlOrNonAscii
|
||||
import okhttp3.internal.lowercase
|
||||
import okhttp3.internal.publicsuffix.PublicSuffixDatabase
|
||||
import okhttp3.internal.toCanonicalHost
|
||||
import okhttp3.internal.trimSubstring
|
||||
|
@ -21,6 +21,7 @@ import okhttp3.HttpUrl.Companion.FORM_ENCODE_SET
|
||||
import okhttp3.HttpUrl.Companion.canonicalize
|
||||
import okhttp3.HttpUrl.Companion.percentDecode
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.toImmutableList
|
||||
import okio.Buffer
|
||||
import okio.BufferedSink
|
||||
|
@ -46,6 +46,7 @@ import okhttp3.internal.headersCheckName
|
||||
import okhttp3.internal.http.toHttpDateOrNull
|
||||
import okhttp3.internal.http.toHttpDateString
|
||||
import okhttp3.internal.http2.Header
|
||||
import okhttp3.internal.lowercase
|
||||
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
||||
|
||||
@Suppress("NAME_SHADOWING")
|
||||
|
@ -26,6 +26,7 @@ import kotlin.text.Charsets.UTF_8
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.internal.canParseAsIpAddress
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.delimiterOffset
|
||||
import okhttp3.internal.indexOfFirstNonAsciiWhitespace
|
||||
import okhttp3.internal.indexOfLastNonAsciiWhitespace
|
||||
|
@ -18,6 +18,7 @@ package okhttp3
|
||||
import java.io.IOException
|
||||
import java.util.UUID
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.toImmutableList
|
||||
import okio.Buffer
|
||||
import okio.BufferedSink
|
||||
|
@ -313,3 +313,10 @@ internal inline fun Any.assertThreadDoesntHoldLock() {
|
||||
throw AssertionError("Thread ${Thread.currentThread().name} MUST NOT hold lock on $this")
|
||||
}
|
||||
}
|
||||
actual inline fun String.lowercase() = this.toLowerCase(Locale.ROOT)
|
||||
|
||||
actual inline fun String.uppercase() = this.toUpperCase(Locale.ROOT)
|
||||
|
||||
fun String.lowercase(locale: Locale) = this.toLowerCase(locale)
|
||||
|
||||
fun String.uppercase(locale: Locale) = this.toUpperCase(locale)
|
||||
|
@ -22,6 +22,7 @@ import java.io.IOException
|
||||
import okhttp3.internal.assertThreadHoldsLock
|
||||
import okhttp3.internal.cache.DiskLruCache.Editor
|
||||
import okhttp3.internal.closeQuietly
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.concurrent.Task
|
||||
import okhttp3.internal.concurrent.TaskRunner
|
||||
import okhttp3.internal.deleteContents
|
||||
|
@ -27,6 +27,7 @@ import okhttp3.CookieJar
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Response
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.headersContentLength
|
||||
import okhttp3.internal.platform.Platform
|
||||
import okhttp3.internal.skipAll
|
||||
|
@ -20,6 +20,7 @@ import java.util.Arrays
|
||||
import java.util.Collections
|
||||
import java.util.LinkedHashMap
|
||||
import okhttp3.internal.and
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.http2.Header.Companion.RESPONSE_STATUS
|
||||
import okhttp3.internal.http2.Header.Companion.TARGET_AUTHORITY
|
||||
import okhttp3.internal.http2.Header.Companion.TARGET_METHOD
|
||||
|
@ -42,6 +42,7 @@ import okhttp3.internal.http2.Header.Companion.TARGET_PATH_UTF8
|
||||
import okhttp3.internal.http2.Header.Companion.TARGET_SCHEME
|
||||
import okhttp3.internal.http2.Header.Companion.TARGET_SCHEME_UTF8
|
||||
import okhttp3.internal.immutableListOf
|
||||
import okhttp3.internal.lowercase
|
||||
import okio.Sink
|
||||
import okio.Source
|
||||
|
||||
|
@ -21,6 +21,7 @@ import java.net.IDN
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import okhttp3.internal.and
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.platform.Platform
|
||||
import okio.GzipSource
|
||||
import okio.buffer
|
||||
|
@ -25,6 +25,7 @@ import java.util.Locale
|
||||
import javax.net.ssl.HostnameVerifier
|
||||
import javax.net.ssl.SSLException
|
||||
import javax.net.ssl.SSLSession
|
||||
import okhttp3.internal.lowercase
|
||||
|
||||
/**
|
||||
* A HostnameVerifier consistent with [RFC 2818][rfc_2818].
|
||||
|
@ -67,6 +67,7 @@ import okhttp3.internal.DoubleInetAddressDns
|
||||
import okhttp3.internal.RecordingOkAuthenticator
|
||||
import okhttp3.internal.addHeaderLenient
|
||||
import okhttp3.internal.closeQuietly
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.http.RecordingProxySelector
|
||||
import okhttp3.internal.userAgent
|
||||
import okhttp3.okio.LoggingFilesystem
|
||||
|
@ -32,6 +32,7 @@ import java.lang.StringBuilder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import okhttp3.internal.and
|
||||
import okhttp3.internal.code
|
||||
import okio.ByteString.Companion.decodeHex
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
|
@ -63,8 +63,10 @@ import okhttp3.TestUtil.assertSuppressed
|
||||
import okhttp3.internal.RecordingAuthenticator
|
||||
import okhttp3.internal.RecordingOkAuthenticator
|
||||
import okhttp3.internal.addHeaderLenient
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.http.HTTP_PERM_REDIRECT
|
||||
import okhttp3.internal.http.HTTP_TEMP_REDIRECT
|
||||
import okhttp3.internal.lowercase
|
||||
import okhttp3.internal.platform.Platform.Companion.get
|
||||
import okhttp3.internal.userAgent
|
||||
import okhttp3.testing.Flaky
|
||||
|
@ -17,7 +17,9 @@ package okhttp3
|
||||
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.format
|
||||
import okhttp3.internal.lowercase
|
||||
import okio.Buffer
|
||||
import okio.ByteString.Companion.encodeUtf8
|
||||
import org.junit.jupiter.api.Assertions.fail
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.format
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
|
@ -41,6 +41,7 @@ import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.util.ArrayDeque
|
||||
import java.util.NoSuchElementException
|
||||
import okhttp3.internal.code
|
||||
|
||||
class FileSystemParamProvider: SimpleProvider() {
|
||||
override fun arguments() = listOf(
|
||||
|
@ -26,6 +26,7 @@ import okhttp3.TestUtil.headerEntries
|
||||
import okhttp3.TestUtil.repeat
|
||||
import okhttp3.internal.EMPTY_BYTE_ARRAY
|
||||
import okhttp3.internal.EMPTY_HEADERS
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.concurrent.TaskFaker
|
||||
import okhttp3.internal.concurrent.TaskRunner
|
||||
import okhttp3.internal.notifyAll
|
||||
|
@ -65,6 +65,7 @@ import okhttp3.TestUtil.repeat
|
||||
import okhttp3.internal.DoubleInetAddressDns
|
||||
import okhttp3.internal.EMPTY_REQUEST
|
||||
import okhttp3.internal.RecordingOkAuthenticator
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.connection.RealConnection
|
||||
import okhttp3.internal.discard
|
||||
import okhttp3.testing.Flaky
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package okhttp3.internal.idn
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ package okhttp3.internal.idn
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.FileSystem
|
||||
import okio.Path.Companion.toPath
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package okhttp3.internal.idn
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
import okio.ByteString.Companion.encodeUtf8
|
||||
|
@ -17,6 +17,7 @@ package okhttp3.internal.ws
|
||||
|
||||
import java.util.Random
|
||||
import okhttp3.TestUtil.repeat
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.format
|
||||
import okhttp3.internal.ws.WebSocketProtocol.OPCODE_BINARY
|
||||
import okhttp3.internal.ws.WebSocketProtocol.OPCODE_TEXT
|
||||
|
@ -16,4 +16,11 @@
|
||||
|
||||
package okhttp3.internal
|
||||
|
||||
import kotlin.text.lowercase as kotlinLowerCase
|
||||
import kotlin.text.uppercase as kotlinUpperCase
|
||||
|
||||
actual typealias HttpUrlRepresentation = String
|
||||
|
||||
actual inline fun String.lowercase() = this.kotlinLowerCase()
|
||||
|
||||
actual inline fun String.uppercase() = this.kotlinUpperCase()
|
||||
|
Reference in New Issue
Block a user