By default you can use HttpResponse or String as possible types for typed
HttpClient requests. So for example:
val htmlContent = client.get<String>("https://en.wikipedia.org/wiki/Main_Page")
val response = client.get<HttpResponse>("https://en.wikipedia.org/wiki/Main_Page")
If JsonFeature is configured, and the server returns the header Content-Type: application/json,
you can also specify a class for deserializing it.
val helloWorld = client.get<HelloWorld>("http://127.0.0.1:8080/")
HttpResponse classFrom an HttpResponse, you can get the response content easily:
val readChannel: ByteReadChannel = response.contentval bytes: ByteArray = response.readBytes()val text: String = response.readText()val readChannel = response.call.receive<ByteReadChannel>()val multiPart = response.call.receive<MultiPartData>()val inputStream = response.call.receive<InputStream>() Remember that InputStream API is synchronous!response.discardRemaining()You can also get the additional response information such as its status, headers, internal state, etc.:
val status: HttpStatusCode = response.statusval headers: Headers = response.headersval call: HttpClientCall = response.callval version: HttpProtocolVersion = response.versionval requestTime: Date = response.requestTimeval responseTime: Date = response.responseTimeval executionContext: Job = response.executionContextval contentType: ContentType? = response.contentType()val charset: Charset? = response.charset()val lastModified: Date? = response.lastModified()val etag: String? = response.etag()val expires: Date? = response.expires()val vary: List<String>? = response.vary()val contentLength: Int? = response.contentLength()val setCookie: List<Cookie> = response.setCookie()