Kotlin Ktor Improves Client-Server Support |
Written by Mike James | |||
Monday, 04 November 2024 | |||
Kotlin Ktor 3 is now available with better performance and improvements including support for server-sent events and CSRF (Cross-Site Request Forgery) protection. Ktor is a free open-source Kotlin framework for building asynchronous servers and clients in connected systems. It was created by the JetBrains Kotlin team using Kotlin and co-routines. This enables it to express complex asynchronous constructs as if they were simple sequential code. It also has the Kotlin advantages of being lightweight and flexible. The new release uses Kotlin 2.0 and switches to kotlinx-io, the official multiplatform asynchronous Kotlin library that provides basic IO primitives. The switch makes Ktor more up to date and better connected with other Kotlin tools. JetBrains says they made the change to standardize IO functionality across Kotlin libraries and improve performance, and that this has been shown in their benchmarks, where some tests based on real-world Ktor applications saw over 90% improvement. Ktor 3 also has initial support for server-sent events (SSE) for both the server and the client. SSE lets servers push events to clients over an HTTP connection, providing a one-way communication channel from the server to the client. The Ktor team says this approach is useful when the server needs to send event-based updates without requiring the client to repeatedly poll for new information. Support has also been added for CSRF (Cross-Site Request Forgery) protection. CSRF attacks trick end users into executing actions on web applications. Attackers typically use social engineering such as sending a link via email or chat to get the user t carry out actions such as transferring funds or changing their email address. The CSRF protection in Ktor is enabled for state-changing operations including POST, PUT, and DELETE. JetBrains says the protection is applicable only for projects that use session cookies and forms, since enabling this can unnecessarily complicate your application. Other improvements include support for WebAssembly (Wasm) as a build target, even though Kotlin/Wasm is still at an early Alpha stage; there's also a new function, staticZip, that allows users to serve the contents of a ZIP archive as static content. Ktor 3 is available now.
More InformationRelated ArticlesThe Programmers Guide To Kotlin - The Class & The Object Kotlin 2 Released With Multiplatform K2 Compiler Kotlin Async Ktor 2.0 Released JetBrains Announces Kotlin Goodies Kotlin 1.5 - Mature But Still Growing <ASIN:1871962900> <ASIN:B07S5CT71C> To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |