christian.steffensen
07/04/2024, 1:43 PMchristian.steffensen
07/04/2024, 1:47 PMHttpResponse.bodyAsText()
Chris Lee
07/04/2024, 2:04 PM401
indicates to the client that it lacks authentication credentials for the requested resource; generally clients will use that response code, in combination with the WWW-Authenticate header in the response, to resend the request with authentication credentials (which may elicit a 403 Forbidden if the credentials are invalid).
RFC.
While the RFC is silent on whether a body is allowed or not, the specified semantics don’t facilitate processing a body as the client is to retry the request with authentication credentials.
Anything beyond that is custom behaviour, assuming the http client could be customized to support that.Aleksei Tirman [JB]
07/04/2024, 2:09 PMephemient
07/04/2024, 2:12 PMthe server SHOULD send a representation containing an explanation of the error situation
the body is not mandatory but expected, especially when https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized
the user agent SHOULD present the enclosed representation to the user
so IMO it's an issue if ktor doesn't allow you to do that