Ktor
Building Asynchronous Servers and Clients in Kotlin
Ktor 1.6.0 Released
We’re happy to announce the availability of Ktor 1.6.0. This minor release brings with it some new features, deprecations, and of course more bug fixes!
Features
This release brings a bunch of new functionality to the client, inline with our goals to have client and server parity.
Client Progress Support
You can now monitor the progress of bytes sent and received in the client, allowing you to for instance provide progress bars in your applications. This was a long-standing issue which has finally been resolved.
val response: HttpResponse = client.post("http://localhost:8080/post") { body = content onUpload { bytesSendTotal: Long, contentLength: Long -> updateUICode() } }
Client Bearer authentication support
The client now supports Bearer authentication, another long-standing issue that has been resolved!
val client = HttpClient() { install(Auth) { bearer { loadTokens { BearerTokens(accessToken = "hello", refreshToken = "world") } refreshTokens { response: HttpResponse -> BearerTokens(accessToken = "hello", refreshToken = "world") } } } }
Ignore trailing slashes
We added a new plugin (new name we’re giving to Features) which tells Ktor to ignore trailing slashes during route matching. To make use of it, simply install the plugin.
install(IgnoreTrailingSlash)
Note that this is meant to be installed a single time and would apply to any `routing` block defined in the application.
Other features and updates
In addition to the above, routing now supports PATCH and PUT generic methods. The TrailingSlashRouteSelector property has now been made public (as was originally intended), and we’ve also added the ability to disable URL encoding on the client.
In addition to the outlined features and numerous bug fixes and documentation improvements, this version
- Updates Dokka to version 1.4.0 with new API documentation. Old API documentation is available for now under api.ktor.io/old.
- Deprecates a series of APIs. While the code itself will show the deprecations, we’ve also put in place a new Migration Guide which we’ll be keeping up to date.
- Fixes a regression issue that affects routing precedence, and in particular was causing issues when declaring static resources.
As always, the release is available on Maven Central, and you can also find/install dependencies using Package Search.
The Ktor Team