-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTOR-7679 Allow disabling body decoding on server (#4444)
* KTOR-7679 Allow disabling body decoding on server
- Loading branch information
Showing
7 changed files
with
137 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1637,6 +1637,8 @@ final val io.ktor.server.http.content/SuppressionAttribute // io.ktor.server.htt | |
final fun <get-SuppressionAttribute>(): io.ktor.util/AttributeKey<kotlin/Boolean> // io.ktor.server.http.content/SuppressionAttribute.<get-SuppressionAttribute>|<get-SuppressionAttribute>(){}[0] | ||
final val io.ktor.server.http.content/isCompressionSuppressed // io.ktor.server.http.content/isCompressionSuppressed|@io.ktor.server.application.ApplicationCall{}isCompressionSuppressed[0] | ||
final fun (io.ktor.server.application/ApplicationCall).<get-isCompressionSuppressed>(): kotlin/Boolean // io.ktor.server.http.content/isCompressionSuppressed.<get-isCompressionSuppressed>|<get-isCompressionSuppressed>@io.ktor.server.application.ApplicationCall(){}[0] | ||
final val io.ktor.server.http.content/isDecompressionSuppressed // io.ktor.server.http.content/isDecompressionSuppressed|@io.ktor.server.application.ApplicationCall{}isDecompressionSuppressed[0] | ||
final fun (io.ktor.server.application/ApplicationCall).<get-isDecompressionSuppressed>(): kotlin/Boolean // io.ktor.server.http.content/isDecompressionSuppressed.<get-isDecompressionSuppressed>|<get-isDecompressionSuppressed>@io.ktor.server.application.ApplicationCall(){}[0] | ||
final val io.ktor.server.logging/mdcProvider // io.ktor.server.logging/mdcProvider|@io.ktor.server.application.Application{}mdcProvider[0] | ||
final fun (io.ktor.server.application/Application).<get-mdcProvider>(): io.ktor.server.logging/MDCProvider // io.ktor.server.logging/mdcProvider.<get-mdcProvider>|<get-mdcProvider>@io.ktor.server.application.Application(){}[0] | ||
final val io.ktor.server.plugins/MutableOriginConnectionPointKey // io.ktor.server.plugins/MutableOriginConnectionPointKey|{}MutableOriginConnectionPointKey[0] | ||
|
@@ -1672,6 +1674,7 @@ final fun (io.ktor.http/HeadersBuilder).io.ktor.server.response/contentRange(kot | |
final fun (io.ktor.http/URLBuilder.Companion).io.ktor.server.util/createFromCall(io.ktor.server.application/ApplicationCall): io.ktor.http/URLBuilder // io.ktor.server.util/createFromCall|[email protected](io.ktor.server.application.ApplicationCall){}[0] | ||
final fun (io.ktor.server.application/Application).io.ktor.server.routing/routing(kotlin/Function1<io.ktor.server.routing/Routing, kotlin/Unit>): io.ktor.server.routing/RoutingRoot // io.ktor.server.routing/routing|[email protected](kotlin.Function1<io.ktor.server.routing.Routing,kotlin.Unit>){}[0] | ||
final fun (io.ktor.server.application/ApplicationCall).io.ktor.server.http.content/suppressCompression() // io.ktor.server.http.content/suppressCompression|[email protected](){}[0] | ||
final fun (io.ktor.server.application/ApplicationCall).io.ktor.server.http.content/suppressDecompression() // io.ktor.server.http.content/suppressDecompression|[email protected](){}[0] | ||
final fun (io.ktor.server.application/ApplicationCall).io.ktor.server.http/push(kotlin/Function1<io.ktor.server.response/ResponsePushBuilder, kotlin/Unit>) // io.ktor.server.http/push|[email protected](kotlin.Function1<io.ktor.server.response.ResponsePushBuilder,kotlin.Unit>){}[0] | ||
final fun (io.ktor.server.application/ApplicationCall).io.ktor.server.http/push(kotlin/String) // io.ktor.server.http/push|[email protected](kotlin.String){}[0] | ||
final fun (io.ktor.server.application/ApplicationCall).io.ktor.server.http/push(kotlin/String, io.ktor.http/Parameters) // io.ktor.server.http/push|[email protected](kotlin.String;io.ktor.http.Parameters){}[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ins/ktor-server-compression/jvm/src/io/ktor/server/plugins/compression/ContentEncoding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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.plugins.compression | ||
|
||
import io.ktor.http.content.* | ||
import io.ktor.server.application.* | ||
import io.ktor.server.response.* | ||
import io.ktor.util.pipeline.* | ||
|
||
internal object ContentEncoding : Hook<suspend ContentEncoding.Context.(PipelineCall) -> Unit> { | ||
|
||
class Context(private val pipelineContext: PipelineContext<Any, PipelineCall>) { | ||
fun transformBody(block: (OutgoingContent) -> OutgoingContent?) { | ||
val transformedContent = block(pipelineContext.subject as OutgoingContent) | ||
if (transformedContent != null) { | ||
pipelineContext.subject = transformedContent | ||
} | ||
} | ||
} | ||
|
||
override fun install( | ||
pipeline: ApplicationCallPipeline, | ||
handler: suspend Context.(PipelineCall) -> Unit | ||
) { | ||
pipeline.sendPipeline.intercept(ApplicationSendPipeline.ContentEncoding) { | ||
handler(Context(this), call) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters