https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktor
  • m

    Marcel Dohnal

    09/02/2019, 3:13 PM
    anyone can tell me where the name ktor comes from? i m giving a talk about it an i asked myself + is there something like a roadmap, couldn't find any...
    d
    m
    • 3
    • 6
  • d

    Darmaheev

    09/03/2019, 6:32 AM
    Hello every one. I have a simple problem but don’t know how to solve it. When I try accessing an endpoint closed by authorization with an expired token, I need to update it using the refresh token and repeat the request. How to add something like an interceptor to the my httpClient? Example code for request:
    val httpClient = HttpClient()
    
    GlobalScope.launch(ApplicationDispatcher) {
        try {
            val url = servUrl
            val json = httpClient.get<String>{
                header("Authorization", "Bearer " + Token.getAccessToken())
                url(url)
            }
    
            success(json)
        } catch (ex: Exception){
            failure(ex)
        }
    I would really appreciate any advice. I’m new at ktor and kotlin
    c
    c
    +2
    • 5
    • 7
  • c

    cy

    09/03/2019, 7:57 AM
    📣 ktor
    1.2.4
    has been released * Fixed multipart form header entity separator * Fixed crypto in IE11 (#1283) * Marked response transient in the client exception (#1256) * Fixed network on main thread in okhttp engine close * Fixed follow redirect iOS (#1000) * Kotlin 1.3.50 * kotlinx.coroutines 1.3.0 Notice: Kotlin 1.3.50 is required to work properly with Kotlin Native JVM: at least kotlin 1.3.41 is required, 1.3.50+ is recommended. https://ktor.io/quickstart/migration/1.2.4.html
    :kotlin-flag: 9
    🎉 30
    :kotlin: 6
    n
    • 2
    • 1
  • t

    Tony Blundell

    09/03/2019, 3:07 PM
    Hi, how do I tell Ktor client to ignore unknown fields when deserializing to an instace of a dataclass with JacksonSerializer?
    d
    c
    • 3
    • 3
  • j

    Jonas Bark

    09/03/2019, 7:48 PM
    With Kotlin 1.3.50 and its Native ready
    typeof
    function, would it now be possible to update KotlinxSerializer to automatically fetch the serializer? So we could get rid of mapping every used serializer for a class
    e
    • 2
    • 1
  • m

    Matthew Browning

    09/04/2019, 12:21 AM
    Does anyone know if there is a way to have an endpoint responds differently depending on if a request is authenticated or not?
    • 1
    • 1
  • b

    bram93

    09/04/2019, 11:02 AM
    Does anyone know how to add an intercepter after the authentication feature? Need it for an custom Authorization feature
    u
    s
    • 3
    • 14
  • d

    David Glasser

    09/04/2019, 5:12 PM
    How does Ktor server (specifically Netty, but in general) behave when the client disconnects, either while still reading the request from it or when writing a response back? Is this something that we have to or can handle? Does the request get cancelled? Is this documented anywhere?
    c
    • 2
    • 1
  • c

    coder82

    09/05/2019, 7:50 AM
    is there an event thrown when server is actually started?
    s
    c
    e
    • 4
    • 27
  • m

    Marcin Wisniowski

    09/05/2019, 9:15 AM
    How do I use compression with ktor client? I added an "Accept-Encoding: gzip, deflate" header to my requests, and now the responses I get are compressed. How do I make ktor decompress them?
    e
    c
    e
    • 4
    • 13
  • b

    bitkid

    09/05/2019, 10:01 PM
    hi! how can i handle a cancelled request? especially cancel coroutine methods called within a request?
    d
    c
    • 3
    • 8
  • l

    legzo

    09/06/2019, 1:27 PM
    Hi guys, I have a question regarding ETags. I added the ConditionalHeaders feature, but I don't understand how it is supposed to work. From what I read in the class, it reads LastModified and ETag headers provided in the request and determines if a 304 must be returned or not. What I don't understand is to what the provided ETag is compared to. Where should I tell Ktor that this resources corresponds to this ETag ? Thanks
    • 1
    • 2
  • s

    Sabeeh

    09/06/2019, 2:36 PM
    gson printing date like this
    2019-09-09 00:00:00
    is there any way to exclude time when data type is Date
    t
    • 2
    • 1
  • a

    altavir

    09/09/2019, 7:21 AM
    I am currently struggling with
    InputStreamAsInput
    . Current implementation seems to be bugged: 1) if I work with dynamic stream like the one I get from socket, it won't work since if input is empty, the input terminates. The input could be empty now, but not empty in the next moment. As a result I can't reliably convert socket input into
    Input
    2) It uses internal
    ByteArray
    pool and external
    IOBuffer
    pool, but sizes of those buffers are not synchronized. If someone would use non-default
    IOBuffer
    , It will probably break things.
    :tnx: 1
    👀 1
    e
    • 2
    • 5
  • b

    bitkid

    09/09/2019, 8:07 AM
    is there an ktor exporter for dropwizard metrics which adds them as a endpoint? so i can query /metrics
    • 1
    • 3
  • s

    Sabeeh

    09/09/2019, 9:39 AM
    any one working on ktor open web admin panel? I’m planning to start a open source ktor web admin panel project or work on if any ongoing
    b
    • 2
    • 1
  • d

    Damian Lall

    09/09/2019, 2:22 PM
    I'm not sure if this is intended behavior, but I'm having trouble with basic authentication and route interception with Ktor. When I set up a basic authentication provider and put a simple
    get
    handler inside an
    authenticate
    block, I'll be prompted for credentials when I try to access the route, so once the
    get
    handler starts being executed, I can access the
    UserIdPrincipal
    and start finding data associated with the account. However, I now want to expand my
    authenticate
    block to include multiple routes, so I thought I could handle the initial processing of the principal/account inside an
    intercept
    block. Yet, when I try to do this, I am not prompted for my credentials and therefore the
    UserIdPrincipal
    inside the interceptor is null. How can I get Ktor to prompt me for my credentials from within a route interceptor inside an
    authenticate
    block?
    s
    • 2
    • 5
  • v

    Vinicius Carvalho

    09/10/2019, 2:24 AM
    Hi folks, a few months ago I've asked about how to get the hostname/port and @cy was kind enough to point me out that it's not possible. I have a similar question again, this time I need to find a way to simulate the same behavior as one would have if running a Servlet and using
    getRequestUrl + getQueryString
    , I know how to obtain the path of a given
    route
    , and the query string, it's also possible to find the
    host
    , but I could not find a way to determine the full original request as in
    <scheme://host:<port>/path?query>
    Is it possible (even without port for now, at least scheme would be nice to have)
    p
    • 2
    • 2
  • s

    snackycracky

    09/10/2019, 9:55 AM
    Hey 🙂 Is there an example somewhere how to use the https://github.com/ktorio/ktor-clients/tree/master/ktor-client-redis ? @e5l
    e
    • 2
    • 1
  • v

    Vinicius Carvalho

    09/10/2019, 1:55 PM
    Hey folks, I'm writing a feature and I have two intercept phases, one before request is processed and other after response is written, I'm using
    pipeline.insertPhaseBefore(ApplicationCallPipeline.Monitoring, phase)
    and
    pipeline.sendPipeline.insertPhaseAfter(ApplicationSendPipeline.After, postSendPhase)
    specifically. Now, when I access the
    ApplicationCall
    request
    and
    response
    is there a way to find the content-length of each? Sorry but it was not clear via the base classes how one would access that information. Thank you
    c
    • 2
    • 3
  • v

    Vinicius Carvalho

    09/10/2019, 5:39 PM
    Sorry for the abuse today folks, but is it possible to add request headers to a ApplicationRequest object? Here's my problem, I'm using an interceptor to add headers to the call, however the target method that receives the payload is outside of my control:
    override fun put(carrier: ApplicationRequest?, key: String?, value: String?) {
    
            }
    • 1
    • 3
  • k

    Kroppeb

    09/10/2019, 8:37 PM
    I tried using
    HttpClient
    but it's unable to find the reference. If I start typeing
    import io.ktor.client
    it can't find it either.
    • 1
    • 3
  • c

    cy

    09/11/2019, 11:29 AM
    📣 ktor
    1.3.0-beta-1
    has been published * ktor client proxy support * Eliminated kotlinx.io dependency * Fixed server identity compression handling: keep original content length * Fixed handling GET requests with body (#1302) * Fixed curl request with empty body * Added iOS url session configuration * Fixed CIO engine no longer sends port in "Host" header (#1295) * Add INTRINSIC value to TLS signature algorithms * Introduced ability to send string in request body * Improved client and server typeOf support with kotlinx.serialization * Gradle 5.4.1+ with newer metadata * Improved exceptions handling in client and server on Android * Added missing TLS parameters and relaxed TLS parsing to ignore unsupported features Breaking changes: -
    <http://kotlinx.io|kotlinx.io>
    dependency has been removed, replace imports: - import
    kotlinx.io.
    ->
    import io.ktor.utils.io.
    - import
    kotlinx.coroutines.io.
    ->
    import io.ktor.utils.io.
    🎉 16
    :kotlin: 9
    👍 1
    :kotlin-flag: 5
    s
    d
    • 3
    • 2
  • f

    Fail

    09/11/2019, 12:18 PM
    Hi all! I have a theoretical question. I want to send files from multiplatform client to serverver. I saw an example.
    val result = <http://client.post|client.post><HttpResponse>("<http://127.0.0.1:$port/handler>") {
                        body = MultiPartContent.build {
                            add("user", "myuser")
                            add("password", "password")
                            add("file", byteArrayOf(1, 2, 3, 4), filename = "binary.bin")
                        }
                    }
    But what will doing if file is big? ByteArraySize could not be more than free RAM. How to send file from IOS and Android to multiplatform without out of memory errors?
    r
    • 2
    • 11
  • s

    Sam Garfinkel

    09/11/2019, 1:52 PM
    What's the best way to send objects from a server via some interchange format (Json/Yaml/etc.) with websockets? Should I just serialize the object, then send the raw string/binary data via the associated Frame?
    d
    • 2
    • 3
  • s

    spand

    09/12/2019, 7:13 AM
    Is performance of ktor being tracked across versions? I ask because we have been running an old pre 1.0 version of ktor and some time ago we tried to update to 1.2.3 but saw our cpu usage double. Both running on the Jetty engine. Only difference is that we also run an older exposed version with the older ktor due to the shared coroutines dependency. Assuming ktor was 10% of our workload then that means the new version would have regressed 10x in performance which seems a bit unbelievable.
    :yes: 1
    e
    c
    • 3
    • 4
  • m

    Marcin Wisniowski

    09/14/2019, 11:51 PM
    Is there a way to use the new
    1.3.0-beta-1
    release from gradle? It isn't published on maven central or jcenter yet but I need the ktor client proxy support. Is there another repo I can add to my gradle file that has it?
    d
    • 2
    • 3
  • b

    bitkid

    09/15/2019, 7:09 PM
    how would you guys structure your REST endpoints with ktor and locationsAPI when the same object can be retrieved by different keys? so i have as an example /api/articles/{id} (id is an UUID) but the same article can be fetched by it's unique name. would you prefer something like /api/articles/by-name/{name} or /api/articles/{name}/by-name or some kind of "polymorphism" where there is a manual check if the parameter is a UUID or a name?
    d
    v
    • 3
    • 6
  • m

    Manuel Lorenzo

    09/16/2019, 1:42 PM
    anybody has some experience with react and ktor? or some other frameworks or technologies for people like me who don’t really know JS?
    b
    b
    • 3
    • 30
  • s

    Sam

    09/16/2019, 2:41 PM
    Hello, Im a newbie in web industry So I have some confuse about
    Ktor
    and
    kotless
    (`https://github.com/JetBrains/kotless`) So why JetBrains build 2 framework at the same time Ktor and Kotless ? Any pros and cons for these framework? Thanks
    z
    t
    • 3
    • 5
Powered by Linen
Title
s

Sam

09/16/2019, 2:41 PM
Hello, Im a newbie in web industry So I have some confuse about
Ktor
and
kotless
(`https://github.com/JetBrains/kotless`) So why JetBrains build 2 framework at the same time Ktor and Kotless ? Any pros and cons for these framework? Thanks
z

Zach Klippenstein (he/him) [MOD]

09/16/2019, 2:45 PM
This is the first time I've seen that project, but it looks like kotless is designed specifically for implementing AWS lambda functions, whereas ktor is a complete server framework
s

Sam

09/16/2019, 2:47 PM
I’m a newbie , so I really don’t understand why Ktor can not implement Aws lamdda functions ? and What different between
AWS lambda functions
and server framework? Thanks @Zach Klippenstein (he/him) [MOD]
z

Zach Klippenstein (he/him) [MOD]

09/16/2019, 3:35 PM
Afaik you could definitely use ktor for that. But it's a lot more heavyweight, and might be seen as overkill. And kotless looks like it has some features that are particularly targeting serverless environments, like automatic warmup
(also I haven't done web dev in a while and so I don't really have any idea what I'm talking about - just inferring from the readme and the couple times I've played with ktor for fun)
t

TanVD

10/07/2019, 2:41 PM
Kotless is not only web server, it also generates Serverless infrastructure. Basically it deploys itself into the AWS, while KTor is a web-server and have nothing to do with deployments 🙂
View count: 3