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
  • g

    Gyeongmin Go

    03/22/2019, 8:54 AM
    Hi everyone, while I develop something with ktor-client and JsonFeature enabled, I wonder is there any way to allow not only "application/json" but for more content types, like "application/x-json". For now, I forked JsonFeature to my project code and added newly defined content-type, and modified code a bit(attach the code fragments below).
    // previous code, io.ktor.client.features.json.JsonFeature
    // JsonFeature.Feature object, and install function
                scope.requestPipeline.intercept(HttpRequestPipeline.Transform) { payload ->
    
                    context.accept(ContentType.Application.Json)
                    if (context.contentType()?.match(ContentType.Application.Json) != true) {
                        return@intercept
                    }
    
                    context.headers.remove(HttpHeaders.ContentType)
                    proceedWith(feature.serializer.write(payload))
                }
    // forked code
    // defined possible content types inside Feature object,
                private val allowedContentTypes = listOf(
                ContentType.Application.Json,
                ContentType.parse("application/x-json")
            )
                scope.requestPipeline.intercept(HttpRequestPipeline.Transform) { payload ->
                    allowedContentTypes.forEach { context.accept(it) }
    
                    if (allowedContentTypes.none { context.contentType()?.match(it) == true })
                        return@intercept
    
                    context.headers.remove(HttpHeaders.ContentType)
                    proceedWith(feature.serializer.write(payload))
                }
    e
    3 replies · 2 participants
  • h

    holgerbrandl

    03/22/2019, 2:05 PM
    What would be the best framework to consume REST apis in Kotlin? I know ktor has a client as well, but I'm wondering if there are other alternatives which are even more tuned for API consumption.
    j
    2 replies · 2 participants
  • t

    Thomas

    03/22/2019, 2:19 PM
    Is there a version of Ktor available which is compatible with Kotlin 1.3.30-eap-45? I'm getting the following exception:
    Exception in thread "main" java.lang.IllegalStateException: Could not find "/Users/thomas/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios-iosx64/1.2.0-alpha-2/e8b5c84525df9fda3ad1e17b950fb2ebb65f4e9d/ktor-client-ios.klib" in [/Users/thomas/AndroidStudioProjects/MyProject/common, /Users/thomas/.konan/klib, /Users/thomas/.konan/kotlin-native-macos-1.2-eap-8554/klib/common, /Users/thomas/.konan/kotlin-native-macos-1.2-eap-8554/klib/platform/ios_x64].
    	at org.jetbrains.kotlin.konan.library.KonanLibraryProperResolver.resolve(SearchPathResolver.kt:194)
    	at org.jetbrains.kotlin.konan.library.SearchPathResolver$DefaultImpls.resolve$default(SearchPathResolver.kt:18)
    	at org.jetbrains.kotlin.konan.library.resolver.impl.KonanLibraryResolverImpl$findLibraries$userProvidedLibraries$1.invoke(KonanLibraryResolverImpl.kt:49)
    	at org.jetbrains.kotlin.konan.library.resolver.impl.KonanLibraryResolverImpl$findLibraries$userProvidedLibraries$1.invoke(KonanLibraryResolverImpl.kt:24)
    	at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:172)
    	at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:698)
    	at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:728)
    	at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:719)
    	at org.jetbrains.kotlin.konan.library.resolver.impl.KonanLibraryResolverImpl.findLibraries(KonanLibraryResolverImpl.kt:50)
    	at org.jetbrains.kotlin.konan.library.resolver.impl.KonanLibraryResolverImpl.resolveWithDependencies(KonanLibraryResolverImpl.kt:32)
    	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:53)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
    c
    j
    +1
    8 replies · 4 participants
  • j

    Jens Baitinger

    03/22/2019, 5:49 PM
    its also not mentioned in the gradle files so it automatically falls back to 1.6
    n
    2 replies · 2 participants
  • s

    ShreemanArjun

    03/23/2019, 2:29 PM
    Anyone give me ideas about implementing refresh counter with simple example?????
    j
    m
    3 replies · 3 participants
  • j

    judrummer

    03/25/2019, 12:54 PM
    Which ktor version works in Kotlin 1.3.30-eap-xx?
    t
    2 replies · 2 participants
  • r

    rocketraman

    03/25/2019, 1:47 PM
    Reposting this for visibility. Still have this problem. Should I create a GitHub issue? Any further debugging I can do before I do that?
    e
    6 replies · 2 participants
  • h

    holgerbrandl

    03/25/2019, 5:55 PM
    Is it a known issue that with the current v1.1.3 the json artefacts are somehow broken because the kotlin serialization sub-dependencies can't be resolved:
    n
    r
    +1
    11 replies · 4 participants
  • r

    Rainer Schlonvoigt

    03/26/2019, 10:13 AM
    really stupid question, but why is it called ktor? Because it 'caters' for your needs?
    h
    3 replies · 2 participants
  • s

    Sergioedcigreja

    03/26/2019, 10:52 AM
    Hey guys, does anyone have an example on how to send a Post request to an url with a File parameter? I’ve tried with submitFormWithBinaryData. When a File is detected it gets the inputStream.asInput(). However the response that I’m getting is not what’s expected.. any ideas?
    g
    7 replies · 2 participants
  • v

    Vinicius Carvalho

    03/26/2019, 2:58 PM
    Hi folks, I think the docs at https://ktor.io/advanced/pipeline/route.html could get some better explanation on the whole interception of a route. reading the section:
    How to intercept preventing additional executions
    its not clear where that
    intercept
    function belongs to. Could someone care to explain how to add an interceptor to any route that could prevent the pipeline to continue (verifying a header)
    m
    1 reply · 2 participants
  • k

    kevin.cianfarini

    03/28/2019, 11:51 PM
    Has there been any work/interest to get ktor to run on kotlin native?
    g
    e
    23 replies · 3 participants
  • a

    alexfacciorusso

    03/29/2019, 10:48 AM
    Hello everyone. I have a question that could be potentially very silly. What is the best way to handle connection errors in a multiplatform project (Android and iOS), when I make a call with Ktor?
    e
    g
    4 replies · 3 participants
  • c

    chan

    03/30/2019, 11:25 AM
    Hello everyone, does anyone know is there a well-known design pattern for this class
    open class Pipeline<TSubject : Any, TContext : Any>(vararg phases: PipelinePhase)
    ? The way it's being used is just so fascinating so I hope to get some insights that I can apply it to my own projects.
    h
    2 replies · 2 participants
  • m

    mp

    03/30/2019, 1:04 PM
    Gotcha. UTF-8 shouldn't be using a BOM. Sure it's not saving in UTF-16? Anyway, one thing you could try just to get more data would be decoding the bytes into a String using a Reader, then having Jackson decode the string. It's unlikely, but there might be a bug in Jackson's native bytes -> UTF8 decoding?
    h
    3 replies · 2 participants
  • l

    legzo

    04/01/2019, 11:15 AM
    Hi guys, I was wondering if there is a way to achieve the following : I have an HTTPClient that calls back-end REST services and tries to read the response as a particular type T. I have installed the ClientLogging feature and everything works as expected, unless the server returns an error, for example an authorization issue, the response cannot be read as T and and exception is thrown, leaving me with no logs. It's a bit hard to debug... As I understand, ClientLogging intercepts at
    HttpReceivePipeline.Before
    with a
    ResponseObserver
    and I don't really understand why my back-ends' logs aren't showing up. Anyone has a clue ?
    e
    7 replies · 2 participants
  • g

    gregorbg

    04/01/2019, 1:15 PM
    When (accidentally) using the wrong username/password for
    BasicAuth
    in the
    io.ktor:ktor-client-auth
    plugin, the exception that gets thrown is a
    SendCountExceedException
    because the engine just tries sending again and again until the treshold is reached/surpassed. How can I change this behaviour so that upon encountering a
    401
    response code a more "proper" error (along the lines of "AuthenticationFailedException") is thrown?
    👀 1
    e
    3 replies · 2 participants
  • o

    otsuka

    04/02/2019, 2:38 AM
    I would like to download a big file using Ktor client and save it. I don’t know how to use
    ByteReadChannel
    . Is there an example code which writes contents to a file from
    ByteReadChannel
    ? https://ktor.io/clients/http-client/calls/responses.html#HttpResponse
    g
    3 replies · 2 participants
  • m

    Michael Pearce

    04/02/2019, 4:58 AM
    I see it's been asked before a few times with no answers, but I thought I'd check to see if anyone has managed to get transaction tracing with New Relic working with Ktor? Currently all transactions are being merged into a single
    /NettyDispatcher
    transaction, because the New Relic agent doesn't have built-in framework support for ktor.
    c
    m
    7 replies · 3 participants
  • l

    legzo

    04/04/2019, 10:41 AM
    Hi guys, I use an Client to make REST calls and I would like to store a value between the request and the response (the goal is to log the elapsed time). I don't really know where I can store this value so that it's available later from a
    ResponseObserver
    . Do you have any clue ?
    e
    2 replies · 2 participants
  • d

    Dennis Schröder

    04/05/2019, 8:20 AM
    Hey guys. I am looking for some best practices / tuts ,/ etc. for Ktor in combination with Kotlin exposed especially about using transactions in coroutines! Would appreciate any suggestions.
    r
    d
    4 replies · 3 participants
  • g

    gaetan

    04/05/2019, 1:22 PM
    Not specifically about Ktor but we just released a plugin to convert HTML code to Kotlinx.html. It makes sense in a Ktor context. https://blog.data2viz.io/post/introducing-kotlinx.html-plugin/
    o
    5 replies · 2 participants
  • j

    jeggy

    04/06/2019, 12:05 AM
    When using Ktor behind a reverse proxy (via Træfik) and using https all my POST requests return instant 403 response. I have tried installed the
    XForwardedHeaderSupport
    module, without any luck. using HTTP works perfectly fine. anyone that knows why this is? or how I should go about debugging this?
    v
    1 reply · 2 participants
  • n

    napperley

    04/07/2019, 11:09 PM
    Is it possible to customise caching for authentication? Would like to have caching cleared for basic authentication every time the server (via Netty) is started.
    b
    10 replies · 2 participants
  • b

    bdawg.io

    04/08/2019, 7:41 PM
    Is there any support for the
    Flow<T>
    preview available for the clients? If not, any suggestions on how it should be approached to integrate into the existing content transformation work?
    g
    3 replies · 2 participants
  • f

    fkrauthan

    04/08/2019, 9:54 PM
    What database framework/library are you guys using for ktor?
    m
    n
    +3
    6 replies · 6 participants
  • n

    napperley

    04/09/2019, 3:41 AM
    Is there a connector for the WSS (WebSocket Secure) protocol? Trying to setup a custom WSS session using a different host and port.
    d
    4 replies · 2 participants
  • r

    rodrigo

    04/09/2019, 11:44 AM
    Hi guys, whenever I use
    HttpRequestBuilder
    and try to specify
    ContentType(ContentType.Application.Json)
    I get
    Header Content-Type is controlled by the engine and cannot be set explicitly
    . I’ve tried adding
    defaultRequest { ContentType }
    into the
    HttpClient {  }
    but I still get the same error. How would I go about setting the content type?
    -.kt
    e
    5 replies · 2 participants
  • m

    mp

    04/10/2019, 11:23 AM
    it probably needs to set cookies as part of that, which won’t work after a response is sent
    l
    1 reply · 2 participants
  • b

    Ben

    04/10/2019, 9:44 PM
    Is there an easy way to create a wildcard path that will match any sub route as well? so it would match
    *
    and
    */*
    and
    */*/*
    e
    1 reply · 2 participants
Powered by Linen
Title
b

Ben

04/10/2019, 9:44 PM
Is there an easy way to create a wildcard path that will match any sub route as well? so it would match
*
and
*/*
and
*/*/*
e

e5l

04/11/2019, 12:57 PM
@cy
View count: 6