Skip to content

Commit

Permalink
Fix case-insensitive checks in other places
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Oct 18, 2024
1 parent 9a99746 commit 8b32a76
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* 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.client.plugins.contentnegotiation
Expand All @@ -16,6 +16,6 @@ public object JsonContentTypeMatcher : ContentTypeMatcher {
}

val value = contentType.withoutParameters().toString()
return value.startsWith("application/") && value.endsWith("+json")
return value.startsWith("application/", ignoreCase = true) && value.endsWith("+json", ignoreCase = true)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* 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.client.plugins.json

Expand All @@ -13,6 +13,6 @@ internal class JsonContentTypeMatcher : ContentTypeMatcher {
}

val value = contentType.withoutParameters().toString()
return value.startsWith("application/") && value.endsWith("+json")
return value.startsWith("application/", ignoreCase = true) && value.endsWith("+json", ignoreCase = true)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2023 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* 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.server.jetty.jakarta
Expand All @@ -8,7 +8,6 @@ import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.response.*
import io.ktor.util.*
import io.ktor.util.cio.*
import io.ktor.util.pipeline.*
import io.ktor.utils.io.*
Expand Down Expand Up @@ -72,7 +71,7 @@ internal class JettyKtorHandler(
) {
try {
val contentType = request.contentType
if (contentType != null && contentType.startsWith("multipart/")) {
if (contentType != null && contentType.startsWith("multipart/", ignoreCase = true)) {
baseRequest.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, multipartConfig)
// TODO someone reported auto-cleanup issues so we have to check it
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* 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.server.jetty
Expand All @@ -8,7 +8,6 @@ import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.response.*
import io.ktor.util.*
import io.ktor.util.cio.*
import io.ktor.util.pipeline.*
import io.ktor.utils.io.*
Expand Down Expand Up @@ -72,7 +71,7 @@ internal class JettyKtorHandler(
) {
try {
val contentType = request.contentType
if (contentType != null && contentType.startsWith("multipart/")) {
if (contentType != null && contentType.startsWith("multipart/", ignoreCase = true)) {
baseRequest.setAttribute(Request.MULTIPART_CONFIG_ELEMENT, multipartConfig)
// TODO someone reported auto-cleanup issues so we have to check it
}
Expand Down

0 comments on commit 8b32a76

Please sign in to comment.