I would like to GET an XML document from a HTTP se...
# ktor
n
I would like to GET an XML document from a HTTP server where the content type is set erroneously to 'xml'.
HttpClient
throws
BadContentTypeFormatException
, is there any way to work around it?
a
You can receive a response body as
ByteArray
and then convert it to a
String
if you need:
Copy code
val client = HttpClient(CIO)
val response = client.get("<http://localhost:5555/>")
val bytes = response.body<ByteArray>()
println(String(bytes))
1
n
@Aleksei Tirman [JB], thanks, it works.