Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("unused")
Expand All @@ -13,7 +13,6 @@ import io.ktor.server.util.*
import io.ktor.util.reflect.*
import io.ktor.utils.io.*
import io.ktor.utils.io.charsets.*
import io.ktor.utils.io.core.*
import kotlinx.io.*
import kotlin.jvm.*

Expand Down Expand Up @@ -121,8 +120,8 @@ public suspend inline fun ApplicationCall.respondRedirect(permanent: Boolean = f
* [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.response.respondText)
*
* @see [io.ktor.server.response.ApplicationResponse]
* @param contentType is an optional [ContentType], default is [ContentType.Text.Plain]
* @param status is an optional [HttpStatusCode], default is [HttpStatusCode.OK]
* @param contentType An optional [ContentType], defaults to [ContentType.Text.Plain]
* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
*/
public suspend fun ApplicationCall.respondText(
text: String,
Expand All @@ -140,8 +139,8 @@ public suspend fun ApplicationCall.respondText(
* [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.response.respondText)
*
* @see [io.ktor.server.response.ApplicationResponse]
* @param contentType is an optional [ContentType], default is [ContentType.Text.Plain]
* @param status is an optional [HttpStatusCode], default is [HttpStatusCode.OK]
* @param contentType An optional [ContentType], defaults to [ContentType.Text.Plain]
* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
*/
public suspend fun ApplicationCall.respondText(
contentType: ContentType? = null,
Expand All @@ -158,8 +157,8 @@ public suspend fun ApplicationCall.respondText(
* [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.response.respondBytes)
*
* @see [io.ktor.server.response.ApplicationResponse]
* @param contentType is an optional [ContentType], unspecified by default
* @param status is an optional [HttpStatusCode], default is [HttpStatusCode.OK]
* @param contentType An optional [ContentType], unspecified by default
* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
*/
public suspend fun ApplicationCall.respondBytes(
contentType: ContentType? = null,
Expand All @@ -175,8 +174,8 @@ public suspend fun ApplicationCall.respondBytes(
* [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.response.respondBytes)
*
* @see [io.ktor.server.response.ApplicationResponse]
* @param contentType is an optional [ContentType], unspecified by default
* @param status is an optional [HttpStatusCode], default is [HttpStatusCode.OK]
* @param contentType An optional [ContentType], unspecified by default
* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
*/
public suspend fun ApplicationCall.respondBytes(
bytes: ByteArray,
Expand All @@ -195,7 +194,7 @@ public suspend fun ApplicationCall.respondBytes(
*
* @param source The binary data source of the content to be responded with.
* @param contentType An optional [ContentType], unspecified by default
* @param status An optional [HttpStatusCode], default is [HttpStatusCode.OK]
* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
* @param contentLength An optional value included in the Content-Length header, also truncating content
*/
public suspend fun ApplicationCall.respondSource(
Expand All @@ -218,6 +217,11 @@ public suspend fun ApplicationCall.respondSource(
* The provided [ByteWriteChannel] will be closed automatically.
*
* [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.response.respondBytesWriter)
*
* @param contentType An optional [ContentType], unspecified by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the default contentType actually ContentType.Application.OctetStream?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnikolova afaik it is used as a default in the Client's defaultTransformers. But on the server, it's chosen depending on the data sent, isn't it? @bjhham

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will automatically populate it with octet stream down the line. Better try it out to see though. Sorry, missed this comment last month 😓

* @param status An optional [HttpStatusCode], defaults to [HttpStatusCode.OK] unless already assigned
* @param contentLength An optional value included in the Content-Length header, also truncating content
* @param producer A function producing content.
*/
public suspend fun ApplicationCall.respondBytesWriter(
contentType: ContentType? = null,
Expand Down