Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ktor monorepo to v3.0.1-eap-1114 #4355

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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