Skip to content

Commit

Permalink
Update ktor monorepo to v3.0.1-eap-1114 (#4355)
Browse files Browse the repository at this point in the history
* Update ktor monorepo to v3.0.1-eap-1114

* Update deprecated API

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Leonid Stashevsky <[email protected]>
  • Loading branch information
renovate[bot] and e5l authored Oct 13, 2024
1 parent f548cb9 commit c99356f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}
}

val ktor_version = "3.0.0-rc-2-eap-1091"
val ktor_version = "3.0.1-eap-1114"

dependencies {
val kotlin_version = libs.versions.kotlin.get()
Expand Down
23 changes: 14 additions & 9 deletions buildSrc/src/main/kotlin/test/server/TestTcpServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,36 @@ internal class TestTcpServer(val port: Int, handler: suspend (Socket) -> Unit) :
override val coroutineContext: CoroutineContext

init {
val server = aSocket(selector).tcp().bind(port = port)
var server: ServerSocket? = null

coroutineContext = GlobalScope.launch {
server = aSocket(selector).tcp().bind(port = port)
while (isActive) {
val socket = try {
server.accept()
server?.accept()
} catch (cause: Throwable) {
println("Test server is fail to accept: $cause")
cause.printStackTrace()
continue
}

try {
socket.use { handler(it) }
} catch (cause: Throwable) {
println("Exception in tcp server: $cause")
cause.printStackTrace()
launch {
try {
socket?.use { handler(it) }
} catch (cause: Throwable) {
println("Exception in tcp server: $cause")
cause.printStackTrace()
}
}
}
}.apply {
invokeOnCompletion {
server.close()
server?.close()
}
}
}

override fun close() { coroutineContext.cancel() }
override fun close() {
coroutineContext.cancel()
}
}
7 changes: 2 additions & 5 deletions buildSrc/src/main/kotlin/test/server/tests/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package test.server.tests
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.server.application.*
import io.ktor.server.http.content.file
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
Expand Down Expand Up @@ -88,13 +89,9 @@ internal fun Application.contentTestServer() {
call.respondText(response.toString())
}
put("/file-upload") {
val parts = call.receiveMultipart().readAllParts()
if (call.request.headers[HttpHeaders.ContentLength] == null) error("Content length is missing")

if (parts.size != 1) call.fail("Invalid form size: $parts")

val file = parts.first() as? PartData.FileItem ?: call.fail("Invalid item")

val file = call.receiveMultipart().readPart() as? PartData.FileItem ?: call.fail("Invalid item")
if (4 != file.headers[HttpHeaders.ContentLength]?.toInt()) call.fail("Size is missing")

val value = file.provider().readInt()
Expand Down

0 comments on commit c99356f

Please sign in to comment.