☎️ Ktor 2.2.4 Release: Takes On Communication Bugs

A popular Kotlin web framework got rid of some annoying communication bugs with the release of Ktor 2.2.4 making API requsts more developer friendly
Ktor is a popular Kotlin based web framework that makes it possible to build a connected application with minimal effort. Ktor is an asynchronous framework for building web apps, microservices, and other things. But even the most robust software can fall victim to bugs, which is why the Ktor development team has recently rolled out a series of bug fixes designed to enhance the framework’s functionality and improve user experience. Let’s take a closer look at some of the recent bug fixes.
⌚ Connect Timeout Is Now Respected When Using The HttpRequestRetry Plugin
The connectTimeoutMillis is not respected and the HttpRequestRetry plugin starts retrying requests. In addition, if the HttpTimeout plugin is installed after HttpRequestRetry the requestTimeoutMillis is not respected as well. This issue has been resolved in the latest release.
🏪 Improved URL Parsing For HTTP Client Requests
Using an underscore in the request URL with Ktor HTTP client would fail the request. Upon calling toURI() or URLBuilder() method, it fails to parse the port and hostname correctly. If you frequently use docker, then you might have come across this bug as hostnames with an underscore are quite common in the docker environments. After the latest release, you can now use the URLs with the underscore without having any issues.
Read to the end for an awesome bonus!
🪲 Wrong Content-Type Now Results In 415 Status Code
Previously, having a wrong content type would result in Error 405, but the problem is the that error should be 415 instead. Error 405 indicates that the server knows the request method, but the target resource doesn’t support this method. But in this scenario, the error should be 415, which indicates that the server refuses to accept the request because the payload format is in unsupported format. After the lasted bug fixes, you will get a correct error message upon entering the wrong content type in the route.
🏋️♀️ Compressing The Response Will Not Result In An Unexpected Error Log
Ktor allows the compression of the outgoing content by using the Compression plugin. But sometimes compressing the response results in an unexpected error log output. This has been fixed now. After the lasted update, the compression will work as intended.
Don’t forget to subscribe!
💎 Forceful Addition Of “charset=UTF-8” In Content-Type Header Resolved
While working with HTTPClient, the Accept-Charset: UTF-8 gets added in a request automatically, if you don’t add any Accept-Charset header. This can cause a problem because Web Application Firewalls with newer standards, refuse requests that contain Accept-Charset. This issue has been resolved according to the latest bug fixes.
You can find the list of bug fixes here, but before you do:
💎 Bonus

Checkout some interesting projects in Kotlin!
Only 1% of people read such long articles to the end. Congrats! It must be a pleasure to talk with you about coding. You are my favorite people, I hope you will connect by subscribing!

BTW. WOW. You can really Kotlin! I’ve designed Kotlin flashcards. What a coincidence! You can order them now!
Do you like Kotlin? Clap, subscribe, like and share in your social media!
Join 3300 developers who follow Tom Smykowski! For $5 per month you will have access to all Medium articles and Tom will get a part of it, so he will write more about Kotlin! Become a member now!
