From e8d2d61149381d49fa8da9481e6d4698fc537233 Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Wed, 25 Sep 2024 09:05:14 +0500 Subject: [PATCH 1/9] KTOR-7470 fix typo --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 61c62f8995b..b09bf5270d0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ # Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. # -# sytleguide +# styleguide kotlin.code.style=official # config From 58d1714e5dadfe446430a492ac739c1058f84601 Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Wed, 25 Sep 2024 09:06:27 +0500 Subject: [PATCH 2/9] KTOR-7470 Remove unused import statements --- ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt index 8cc049fb369..c81c76db27a 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt @@ -11,7 +11,6 @@ import io.ktor.utils.io.core.* import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.io.* -import kotlinx.io.IOException import kotlinx.io.bytestring.* import java.io.EOFException import java.nio.* From 5735df8126609bfa5590554b231f709c68daa6ca Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Wed, 25 Sep 2024 09:08:17 +0500 Subject: [PATCH 3/9] KTOR-7470 Rethrow UnsupportedMediaTypeException if content type header is not present or is invalid --- .../src/io/ktor/server/plugins/Errors.kt | 8 ++- .../ktor/server/engine/DefaultTransformJvm.kt | 23 +++++--- .../tests/server/engine/MultiPartDataTest.kt | 55 +++++++++++++++++++ 3 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt diff --git a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt index 8c672d512f0..2bd58ebbfcb 100644 --- a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt +++ b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt @@ -85,9 +85,11 @@ public class CannotTransformContentToTypeException( */ @OptIn(ExperimentalCoroutinesApi::class) public class UnsupportedMediaTypeException( - private val contentType: ContentType -) : ContentTransformationException("Content type $contentType is not supported"), - CopyableThrowable { + private val contentType: ContentType? +) : ContentTransformationException( + contentType?.let { "Content type $it is not supported" } + ?: "Content-Type header is required for multipart processing" +), CopyableThrowable { override fun createCopy(): UnsupportedMediaTypeException = UnsupportedMediaTypeException(contentType).also { it.initCauseBridge(this) diff --git a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt index dd3c7d43079..3646f257a1c 100644 --- a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt +++ b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt @@ -8,6 +8,7 @@ import io.ktor.http.* import io.ktor.http.cio.* import io.ktor.http.content.* import io.ktor.server.application.* +import io.ktor.server.plugins.UnsupportedMediaTypeException import io.ktor.server.request.* import io.ktor.util.pipeline.* import io.ktor.utils.io.* @@ -17,6 +18,7 @@ import io.ktor.utils.io.streams.* import kotlinx.coroutines.* import kotlinx.io.* import java.io.* +import java.io.IOException internal actual suspend fun PipelineContext.defaultPlatformTransformations( query: Any @@ -33,16 +35,21 @@ internal actual suspend fun PipelineContext.defaultPlatformTr @OptIn(InternalAPI::class) internal actual fun PipelineContext<*, PipelineCall>.multiPartData(rc: ByteReadChannel): MultiPartData { val contentType = call.request.header(HttpHeaders.ContentType) - ?: throw IllegalStateException("Content-Type header is required for multipart processing") + ?: throw UnsupportedMediaTypeException(null) val contentLength = call.request.header(HttpHeaders.ContentLength)?.toLong() - return CIOMultipartDataBase( - coroutineContext + Dispatchers.Unconfined, - rc, - contentType, - contentLength, - call.formFieldLimit - ) + + try { + return CIOMultipartDataBase( + coroutineContext + Dispatchers.Unconfined, + rc, + contentType, + contentLength, + call.formFieldLimit + ) + } catch (_: IOException) { + throw UnsupportedMediaTypeException(ContentType.parse(contentType)) + } } internal actual fun Source.readTextWithCustomCharset(charset: Charset): String = diff --git a/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt new file mode 100644 index 00000000000..3b7169096d5 --- /dev/null +++ b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt @@ -0,0 +1,55 @@ +/* + * 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.tests.server.engine + +import io.ktor.http.* +import io.ktor.server.application.* +import io.ktor.server.engine.multiPartData +import io.ktor.server.plugins.UnsupportedMediaTypeException +import io.ktor.server.request.* +import io.ktor.util.pipeline.* +import io.ktor.utils.io.* +import io.mockk.* +import kotlinx.coroutines.* +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.runTest +import kotlin.test.* + +class MultiPartDataTest { + private val mockContext = mockk>(relaxed = true) + private val mockRequest = mockk(relaxed = true) + private val testScope = TestScope() + + @Test + fun givenRequest_whenNoContentTypeHeaderPresent_thenUnsupportedMediaTypeException() { + // Setup + every { mockContext.call.request } returns mockRequest + every { mockRequest.header(HttpHeaders.ContentType) } returns null + + // Act & Assert + assertFailsWith { + runBlocking { mockContext.multiPartData(ByteReadChannel("sample data")) } + } + } + + @Test + fun givenWrongContentType_whenProcessMultiPart_thenUnsupportedMediaTypeException() { + // Given + val rc = ByteReadChannel("sample data") + val contentType = "test/plain; boundary=test" + val contentLength = "123" + every { mockContext.call.request } returns mockRequest + every { mockContext.call.attributes.getOrNull(any()) } returns 0L + every { mockRequest.header(HttpHeaders.ContentType) } returns contentType + every { mockRequest.header(HttpHeaders.ContentLength) } returns contentLength + + // When & Then + testScope.runTest { + assertFailsWith { + mockContext.multiPartData(rc) + } + } + } +} From 3eba61eb2223dee98656a95ec5a371a5bff78137 Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Thu, 10 Oct 2024 17:25:06 +0500 Subject: [PATCH 4/9] KTOR-7470 generalize UnsupportedMediaException message when content-type is absent --- .../common/src/io/ktor/server/plugins/Errors.kt | 2 +- .../jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt index 2bd58ebbfcb..d07bdc18240 100644 --- a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt +++ b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt @@ -88,7 +88,7 @@ public class UnsupportedMediaTypeException( private val contentType: ContentType? ) : ContentTransformationException( contentType?.let { "Content type $it is not supported" } - ?: "Content-Type header is required for multipart processing" + ?: "Content-Type header is required" ), CopyableThrowable { override fun createCopy(): UnsupportedMediaTypeException = UnsupportedMediaTypeException(contentType).also { diff --git a/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt index 3b7169096d5..66e5a7550fb 100644 --- a/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt +++ b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt @@ -24,11 +24,11 @@ class MultiPartDataTest { @Test fun givenRequest_whenNoContentTypeHeaderPresent_thenUnsupportedMediaTypeException() { - // Setup + // Given every { mockContext.call.request } returns mockRequest every { mockRequest.header(HttpHeaders.ContentType) } returns null - // Act & Assert + // When & Then assertFailsWith { runBlocking { mockContext.multiPartData(ByteReadChannel("sample data")) } } From 28c4a2e9a538cb6d7b4669f3a4013a8ee969a253 Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Fri, 11 Oct 2024 10:01:28 +0500 Subject: [PATCH 5/9] KTOR-7470 throw UnsupportedMediaTypeException only if message contains "Content-Type" --- .../jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt index 3646f257a1c..2efce45e862 100644 --- a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt +++ b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt @@ -47,8 +47,11 @@ internal actual fun PipelineContext<*, PipelineCall>.multiPartData(rc: ByteReadC contentLength, call.formFieldLimit ) - } catch (_: IOException) { - throw UnsupportedMediaTypeException(ContentType.parse(contentType)) + } catch (e: IOException) { + if (e.message?.contains("Content-Type") == true) { + throw UnsupportedMediaTypeException(ContentType.parse(contentType)) + } + throw e } } From 0ccca304d2f6c40fcc5513156b176b17468eb87b Mon Sep 17 00:00:00 2001 From: Gleb Nazarov Date: Thu, 14 Nov 2024 16:19:03 +0500 Subject: [PATCH 6/9] KTOR-7470 add UnsupportedMediaTypeException for CIO module --- .../ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt | 9 +++++++++ .../ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt | 4 ++-- .../jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt | 8 ++------ 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt new file mode 100644 index 00000000000..058ca6576f2 --- /dev/null +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt @@ -0,0 +1,9 @@ +/* + * 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.http.cio + +import kotlinx.io.IOException + +public class UnsupportedMediaTypeExceptionCIO(message: String) : IOException(message) diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt index 3eeab2f5afa..1c8b4e5427f 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt @@ -138,7 +138,7 @@ public fun CoroutineScope.parseMultipart( headers: HttpHeadersMap, maxPartSize: Long = Long.MAX_VALUE ): ReceiveChannel { - val contentType = headers["Content-Type"] ?: throw IOException("Failed to parse multipart: no Content-Type header") + val contentType = headers["Content-Type"] ?: throw UnsupportedMediaTypeExceptionCIO("Failed to parse multipart: no Content-Type header") val contentLength = headers["Content-Length"]?.parseDecLong() return parseMultipart(input, contentType, contentLength, maxPartSize) @@ -154,7 +154,7 @@ public fun CoroutineScope.parseMultipart( maxPartSize: Long = Long.MAX_VALUE, ): ReceiveChannel { if (!contentType.startsWith("multipart/", ignoreCase = true)) { - throw IOException("Failed to parse multipart: Content-Type should be multipart/* but it is $contentType") + throw UnsupportedMediaTypeExceptionCIO("Failed to parse multipart: Content-Type should be multipart/* but it is $contentType") } val boundaryByteBuffer = parseBoundaryInternal(contentType) val boundaryBytes = ByteString(boundaryByteBuffer) diff --git a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt index 2efce45e862..37a110a1ee0 100644 --- a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt +++ b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt @@ -18,7 +18,6 @@ import io.ktor.utils.io.streams.* import kotlinx.coroutines.* import kotlinx.io.* import java.io.* -import java.io.IOException internal actual suspend fun PipelineContext.defaultPlatformTransformations( query: Any @@ -47,11 +46,8 @@ internal actual fun PipelineContext<*, PipelineCall>.multiPartData(rc: ByteReadC contentLength, call.formFieldLimit ) - } catch (e: IOException) { - if (e.message?.contains("Content-Type") == true) { - throw UnsupportedMediaTypeException(ContentType.parse(contentType)) - } - throw e + } catch (_: UnsupportedMediaTypeExceptionCIO) { + throw UnsupportedMediaTypeException(ContentType.parse(contentType)) } } From 814cea1b134bda7dc2a54fdb00b5ddd679350eeb Mon Sep 17 00:00:00 2001 From: Mariia Skripchenko <61115099+marychatte@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:47:58 +0100 Subject: [PATCH 7/9] fix codestyle, run apiDump, add test, add @InternalAPI --- .../jvm/src/io/ktor/http/cio/Errors.kt | 2 ++ .../jvm/src/io/ktor/http/cio/Multipart.kt | 10 ++++-- .../api/ktor-server-core.klib.api | 2 +- .../src/io/ktor/server/plugins/Errors.kt | 3 +- .../tests/server/engine/MultiPartDataTest.kt | 31 ++++++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt index 058ca6576f2..d3866bb7dbe 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt @@ -4,6 +4,8 @@ package io.ktor.http.cio +import io.ktor.utils.io.* import kotlinx.io.IOException +@InternalAPI public class UnsupportedMediaTypeExceptionCIO(message: String) : IOException(message) diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt index 1c8b4e5427f..3a18bb31e80 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt +++ b/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Multipart.kt @@ -133,12 +133,15 @@ private suspend fun ByteReadChannel.skipIfFoundReadCount(prefix: ByteString): Lo /** * Starts a multipart parser coroutine producing multipart events */ +@OptIn(InternalAPI::class) public fun CoroutineScope.parseMultipart( input: ByteReadChannel, headers: HttpHeadersMap, maxPartSize: Long = Long.MAX_VALUE ): ReceiveChannel { - val contentType = headers["Content-Type"] ?: throw UnsupportedMediaTypeExceptionCIO("Failed to parse multipart: no Content-Type header") + val contentType = headers["Content-Type"] ?: throw UnsupportedMediaTypeExceptionCIO( + "Failed to parse multipart: no Content-Type header" + ) val contentLength = headers["Content-Length"]?.parseDecLong() return parseMultipart(input, contentType, contentLength, maxPartSize) @@ -147,6 +150,7 @@ public fun CoroutineScope.parseMultipart( /** * Starts a multipart parser coroutine producing multipart events */ +@OptIn(InternalAPI::class) public fun CoroutineScope.parseMultipart( input: ByteReadChannel, contentType: CharSequence, @@ -154,7 +158,9 @@ public fun CoroutineScope.parseMultipart( maxPartSize: Long = Long.MAX_VALUE, ): ReceiveChannel { if (!contentType.startsWith("multipart/", ignoreCase = true)) { - throw UnsupportedMediaTypeExceptionCIO("Failed to parse multipart: Content-Type should be multipart/* but it is $contentType") + throw UnsupportedMediaTypeExceptionCIO( + "Failed to parse multipart: Content-Type should be multipart/* but it is $contentType" + ) } val boundaryByteBuffer = parseBoundaryInternal(contentType) val boundaryBytes = ByteString(boundaryByteBuffer) diff --git a/ktor-server/ktor-server-core/api/ktor-server-core.klib.api b/ktor-server/ktor-server-core/api/ktor-server-core.klib.api index 75e902b0407..c121f0136a9 100644 --- a/ktor-server/ktor-server-core/api/ktor-server-core.klib.api +++ b/ktor-server/ktor-server-core/api/ktor-server-core.klib.api @@ -697,7 +697,7 @@ final class io.ktor.server.plugins/PayloadTooLargeException : io.ktor.server.plu } final class io.ktor.server.plugins/UnsupportedMediaTypeException : io.ktor.server.plugins/ContentTransformationException, kotlinx.coroutines/CopyableThrowable { // io.ktor.server.plugins/UnsupportedMediaTypeException|null[0] - constructor (io.ktor.http/ContentType) // io.ktor.server.plugins/UnsupportedMediaTypeException.|(io.ktor.http.ContentType){}[0] + constructor (io.ktor.http/ContentType?) // io.ktor.server.plugins/UnsupportedMediaTypeException.|(io.ktor.http.ContentType?){}[0] final fun createCopy(): io.ktor.server.plugins/UnsupportedMediaTypeException // io.ktor.server.plugins/UnsupportedMediaTypeException.createCopy|createCopy(){}[0] } diff --git a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt index d07bdc18240..8b1393be592 100644 --- a/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt +++ b/ktor-server/ktor-server-core/common/src/io/ktor/server/plugins/Errors.kt @@ -89,7 +89,8 @@ public class UnsupportedMediaTypeException( ) : ContentTransformationException( contentType?.let { "Content type $it is not supported" } ?: "Content-Type header is required" -), CopyableThrowable { +), + CopyableThrowable { override fun createCopy(): UnsupportedMediaTypeException = UnsupportedMediaTypeException(contentType).also { it.initCauseBridge(this) diff --git a/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt index 66e5a7550fb..5f3934ed78b 100644 --- a/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt +++ b/ktor-server/ktor-server-core/jvm/test/io/ktor/tests/server/engine/MultiPartDataTest.kt @@ -4,17 +4,20 @@ package io.ktor.tests.server.engine +import io.ktor.client.request.* import io.ktor.http.* import io.ktor.server.application.* -import io.ktor.server.engine.multiPartData -import io.ktor.server.plugins.UnsupportedMediaTypeException +import io.ktor.server.engine.* +import io.ktor.server.plugins.* import io.ktor.server.request.* +import io.ktor.server.response.* +import io.ktor.server.routing.* +import io.ktor.server.testing.* import io.ktor.util.pipeline.* import io.ktor.utils.io.* import io.mockk.* import kotlinx.coroutines.* -import kotlinx.coroutines.test.TestScope -import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.* import kotlin.test.* class MultiPartDataTest { @@ -52,4 +55,24 @@ class MultiPartDataTest { } } } + + @Test + fun testUnsupportedMediaTypeStatusCode() = testApplication { + routing { + post { + call.receiveMultipart() + call.respond(HttpStatusCode.OK) + } + } + + client.post { + accept(ContentType.Text.Plain) + }.apply { + assertEquals(HttpStatusCode.UnsupportedMediaType, status) + } + + client.post {}.apply { + assertEquals(HttpStatusCode.UnsupportedMediaType, status) + } + } } From 1a9ef52770f0c3881ef0addeb81361a4698692c1 Mon Sep 17 00:00:00 2001 From: Mariia Skripchenko <61115099+marychatte@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:30:10 +0100 Subject: [PATCH 8/9] run apiDump --- ktor-http/ktor-http-cio/api/ktor-http-cio.api | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ktor-http/ktor-http-cio/api/ktor-http-cio.api b/ktor-http/ktor-http-cio/api/ktor-http-cio.api index be316981f41..dfbabf6d5dd 100644 --- a/ktor-http/ktor-http-cio/api/ktor-http-cio.api +++ b/ktor-http/ktor-http-cio/api/ktor-http-cio.api @@ -142,6 +142,10 @@ public final class io/ktor/http/cio/Response : io/ktor/http/cio/HttpMessage { public final fun getVersion ()Ljava/lang/CharSequence; } +public final class io/ktor/http/cio/UnsupportedMediaTypeExceptionCIO : java/io/IOException { + public fun (Ljava/lang/String;)V +} + public final class io/ktor/http/cio/internals/CharsKt { public static final fun parseDecLong (Ljava/lang/CharSequence;)J } From 601efacd4b15b4ff231bf265dedec0580d2ef19e Mon Sep 17 00:00:00 2001 From: Mariia Skripchenko <61115099+marychatte@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:49:09 +0100 Subject: [PATCH 9/9] move Errors.kt from jvm to common --- ktor-http/ktor-http-cio/api/ktor-http-cio.api | 8 ++++---- ktor-http/ktor-http-cio/api/ktor-http-cio.klib.api | 4 ++++ .../src/io/ktor/http/cio/internals}/Errors.kt | 2 +- .../jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) rename ktor-http/ktor-http-cio/{jvm/src/io/ktor/http/cio => common/src/io/ktor/http/cio/internals}/Errors.kt (89%) diff --git a/ktor-http/ktor-http-cio/api/ktor-http-cio.api b/ktor-http/ktor-http-cio/api/ktor-http-cio.api index dfbabf6d5dd..d322a02cec2 100644 --- a/ktor-http/ktor-http-cio/api/ktor-http-cio.api +++ b/ktor-http/ktor-http-cio/api/ktor-http-cio.api @@ -142,10 +142,6 @@ public final class io/ktor/http/cio/Response : io/ktor/http/cio/HttpMessage { public final fun getVersion ()Ljava/lang/CharSequence; } -public final class io/ktor/http/cio/UnsupportedMediaTypeExceptionCIO : java/io/IOException { - public fun (Ljava/lang/String;)V -} - public final class io/ktor/http/cio/internals/CharsKt { public static final fun parseDecLong (Ljava/lang/CharSequence;)J } @@ -159,3 +155,7 @@ public final class io/ktor/http/cio/internals/MutableRange { public fun toString ()Ljava/lang/String; } +public final class io/ktor/http/cio/internals/UnsupportedMediaTypeExceptionCIO : java/io/IOException { + public fun (Ljava/lang/String;)V +} + diff --git a/ktor-http/ktor-http-cio/api/ktor-http-cio.klib.api b/ktor-http/ktor-http-cio/api/ktor-http-cio.klib.api index 2418cb5200d..39891106013 100644 --- a/ktor-http/ktor-http-cio/api/ktor-http-cio.klib.api +++ b/ktor-http/ktor-http-cio/api/ktor-http-cio.klib.api @@ -27,6 +27,10 @@ final class io.ktor.http.cio.internals/MutableRange { // io.ktor.http.cio.intern final fun toString(): kotlin/String // io.ktor.http.cio.internals/MutableRange.toString|toString(){}[0] } +final class io.ktor.http.cio.internals/UnsupportedMediaTypeExceptionCIO : kotlinx.io/IOException { // io.ktor.http.cio.internals/UnsupportedMediaTypeExceptionCIO|null[0] + constructor (kotlin/String) // io.ktor.http.cio.internals/UnsupportedMediaTypeExceptionCIO.|(kotlin.String){}[0] +} + final class io.ktor.http.cio/CIOHeaders : io.ktor.http/Headers { // io.ktor.http.cio/CIOHeaders|null[0] constructor (io.ktor.http.cio/HttpHeadersMap) // io.ktor.http.cio/CIOHeaders.|(io.ktor.http.cio.HttpHeadersMap){}[0] diff --git a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt b/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/Errors.kt similarity index 89% rename from ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt rename to ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/Errors.kt index d3866bb7dbe..cb9fa810822 100644 --- a/ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/Errors.kt +++ b/ktor-http/ktor-http-cio/common/src/io/ktor/http/cio/internals/Errors.kt @@ -2,7 +2,7 @@ * 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.http.cio +package io.ktor.http.cio.internals import io.ktor.utils.io.* import kotlinx.io.IOException diff --git a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt index 37a110a1ee0..a5379f8e5e7 100644 --- a/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt +++ b/ktor-server/ktor-server-core/jvm/src/io/ktor/server/engine/DefaultTransformJvm.kt @@ -6,6 +6,7 @@ package io.ktor.server.engine import io.ktor.http.* import io.ktor.http.cio.* +import io.ktor.http.cio.internals.* import io.ktor.http.content.* import io.ktor.server.application.* import io.ktor.server.plugins.UnsupportedMediaTypeException