mirror of
https://github.com/square/okhttp.git
synced 2025-07-31 05:04:26 +03:00
Revert downgrade to 1.4 for gradle reasons (#7391)
* Revert "Downgrade to kotlin apiVersion 1.4 (#7267)" * Revert "Improve runtime compatibility with kotlin 1.5.31 (#7343)" * Revert "Remove usage of toDuration() (#7329)"
This commit is contained in:
@ -115,9 +115,7 @@ subprojects {
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
apiVersion = "1.4"
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xjvm-default=all",
|
||||
"-opt-in=kotlin.RequiresOptIn"
|
||||
|
@ -75,7 +75,6 @@ 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, ExperimentalTime::class)
|
||||
@file:OptIn(ExperimentalCoroutinesApi::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
@ -39,7 +39,6 @@ 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,7 +16,6 @@
|
||||
package okhttp3.sse.internal
|
||||
|
||||
import java.io.IOException
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.toLongOrDefault
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
|
@ -17,7 +17,6 @@ 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,7 +16,6 @@
|
||||
package okhttp3.tls.internal.der
|
||||
|
||||
import java.math.BigInteger
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.BufferedSink
|
||||
import okio.ByteString
|
||||
|
@ -13,13 +13,9 @@
|
||||
* 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,13 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3.internal
|
||||
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.toDuration
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Headers
|
||||
|
@ -394,17 +394,3 @@ 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,9 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package okhttp3
|
||||
|
||||
import assertk.assertThat
|
||||
@ -24,7 +21,6 @@ import assertk.assertions.isFalse
|
||||
import assertk.assertions.isTrue
|
||||
import kotlin.test.Test
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
class CacheControlTest {
|
||||
@Test
|
||||
|
@ -20,7 +20,6 @@ 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,7 +31,6 @@ 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,18 +13,18 @@
|
||||
* 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
|
||||
import okhttp3.internal.commonForceNetwork
|
||||
import okhttp3.internal.commonImmutable
|
||||
import okhttp3.internal.commonMaxAge
|
||||
import okhttp3.internal.commonMaxStale
|
||||
import okhttp3.internal.commonMinFresh
|
||||
import okhttp3.internal.commonNoCache
|
||||
import okhttp3.internal.commonNoStore
|
||||
import okhttp3.internal.commonNoTransform
|
||||
@ -150,18 +150,11 @@ actual class CacheControl internal actual constructor(
|
||||
|
||||
actual fun immutable() = commonImmutable()
|
||||
|
||||
// We are compiling with kotlin 1.6 but need to run with older versions at runtime. For
|
||||
// maximum compat we therefore need to handle both the case where DurationUnit is typealiased
|
||||
// to TimeUnit (as it was pre-1.6) and where it is a distinct wrapper enum (in 1.6). We also
|
||||
// can't use durationUnit.toTimeUnit() because that doesn't exist in the typealiased case.
|
||||
// This function should work in either case.
|
||||
internal fun toJavaTimeUnit(durationUnit: DurationUnit) = TimeUnit.valueOf(durationUnit.name)
|
||||
actual fun maxAge(maxAge: Int, timeUnit: DurationUnit) = commonMaxAge(maxAge, timeUnit)
|
||||
|
||||
actual fun maxAge(maxAge: Int, timeUnit: DurationUnit) = maxAge(maxAge, toJavaTimeUnit(timeUnit))
|
||||
actual fun maxStale(maxStale: Int, timeUnit: DurationUnit) = commonMaxStale(maxStale, timeUnit)
|
||||
|
||||
actual fun maxStale(maxStale: Int, timeUnit: DurationUnit) = maxStale(maxStale, toJavaTimeUnit(timeUnit))
|
||||
|
||||
actual fun minFresh(minFresh: Int, timeUnit: DurationUnit) = minFresh(minFresh, toJavaTimeUnit(timeUnit))
|
||||
actual fun minFresh(minFresh: Int, timeUnit: DurationUnit) = commonMinFresh(minFresh, timeUnit)
|
||||
|
||||
/**
|
||||
* Sets the maximum age of a cached response. If the cache response's age exceeds [maxAge], it
|
||||
|
@ -23,7 +23,6 @@ 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,12 +23,10 @@ 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,7 +21,6 @@ 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,7 +46,6 @@ 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,7 +26,6 @@ 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,7 +18,6 @@ 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,10 +313,3 @@ 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,7 +22,6 @@ 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,7 +27,6 @@ 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,7 +20,6 @@ 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,7 +42,6 @@ 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,7 +21,6 @@ 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,7 +25,6 @@ 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,7 +67,6 @@ 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,7 +32,6 @@ 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,10 +63,8 @@ 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,9 +17,7 @@ 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,7 +15,6 @@
|
||||
*/
|
||||
package okhttp3
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okhttp3.internal.format
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
|
@ -41,7 +41,6 @@ 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,7 +26,6 @@ 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,7 +65,6 @@ 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,7 +15,6 @@
|
||||
*/
|
||||
package okhttp3.internal.idn
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,6 @@ 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,7 +15,6 @@
|
||||
*/
|
||||
package okhttp3.internal.idn
|
||||
|
||||
import okhttp3.internal.code
|
||||
import okio.Buffer
|
||||
import okio.BufferedSource
|
||||
import okio.ByteString.Companion.encodeUtf8
|
||||
|
@ -17,7 +17,6 @@ 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,11 +16,4 @@
|
||||
|
||||
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