You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps it is logical that usecase 1 has a null value for TextContent#status because it is not an actual TextContent. However, I would expect for usecase 2 that ApplicationResponse#status() would be set.
tl;dr: There is no single source of truth for getting the statuscode (which I would expect to be ApplicationResponse#status().
The text was updated successfully, but these errors were encountered:
FWIW, if you wanted one place, it seems like it can always be retrieved from the subject as OutgoingContent after the Render phase:
/** * Phase to render any current pipeline subject into [io.ktor.http.content.OutgoingContent] * * Beyond this phase only [io.ktor.http.content.OutgoingContent] should be produced by any interceptor*/valRender=PipelinePhase("Render")
The caveat is that it can still be null if no status code was provided in a respond(...) (as in, doesn't get defaulted to 200).
That said, this information feels like it certainly should be available in the response API.
Given the following code:
call.respond(HttpStatusCode.InternalServerError, "{}")
call.respondText("{}", ContentType.Application.Json, HttpStatusCode.InternalServerError)
I am intercepting the response in the 'after' of the 'sendPipeline':
The results for this interceptor are as following:
ApplicationResponse#status()
TextContent#status
call.respond(HttpStatusCode.InternalServerError, "{}")
500 Internal Server Error
null
call.respondText("{}", ContentType.Application.Json, HttpStatusCode.InternalServerError)
null
500 Internal Server Error
Perhaps it is logical that usecase 1 has a null value for
TextContent#status
because it is not an actualTextContent
. However, I would expect for usecase 2 thatApplicationResponse#status()
would be set.tl;dr: There is no single source of truth for getting the statuscode (which I would expect to be
ApplicationResponse#status()
.The text was updated successfully, but these errors were encountered: