https://kotlinlang.org logo
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
  • e

    Eduard Boloș

    08/11/2018, 12:51 PM
    so I was doing some debugging, and it seems that the call to
    tryGetString
    with path
    ktor.deployment.port
    for value
    ${?PORT}
    (that is coming from the included file) is not resolved for some reason. I will probably stop debugging now and I will open an issue on GH a bit later. thanks for you reply, Ilya!
    o
    • 2
    • 3
  • e

    Eduard Boloș

    08/12/2018, 9:47 PM
    another question: is it possible to use Config4k (https://github.com/config4k/config4k) with ktor? I didn’t find any way to access the underlying
    com.typesafe.config.Config
    object, am I missing something?
    r
    • 2
    • 2
  • t

    Tim Castelijns

    08/14/2018, 7:36 AM
    when I
    install(HttpCookies)
    on apache client and make a call I get issue
    DateTimeParseException: Text 'Mon, 13-Aug-2018 07:33:04 GMT' could not be parsed at index 7
    I suppose I have to specify a datetime format somewhere but I haven’t been able to find how to do this
    👀 1
    e
    d
    • 3
    • 25
  • t

    Tim Castelijns

    08/14/2018, 10:25 AM
    using HttpClient(Apache) with the default AcceptAllCookiesStorage. Are cookies shared between a.com and b.a.com?
    e
    • 2
    • 15
  • v

    vincent.brule

    08/14/2018, 12:50 PM
    Hello, I use response.readTest() to obtain the body string but for a long response it’s take a long time. Is it a solution to optimize that please ?
    o
    c
    e
    • 4
    • 54
  • u

    uhe

    08/14/2018, 1:09 PM
    is something wrong with the ktor artifacts on bintray? we're getting build errors here because our buildagent can't download the
    ktor-server-core
    artifact..
    [14:55:31][Gradle failure report] > Could not download ktor-server-core.jar (io.ktor:ktor-server-core:0.9.3)
    [14:55:31][Gradle failure report] > Could not get resource 'http://dl.bintray.com/kotlin/ktor/io/ktor/ktor-server-core/0.9.3/ktor-server-core-0.9.3.jar'.
    [14:55:31][Gradle failure report] > Connection reset
    d
    c
    m
    • 4
    • 9
  • r

    rocketraman

    08/14/2018, 10:45 PM
    @Deactivated User What is this reference to
    copyToSuspend
    @ https://ktor.io/servers/uploads.html ? I suspect that should just be
    copyTo
    right?
    d
    • 2
    • 13
  • z

    zpearce

    08/14/2018, 10:45 PM
    is there a way to get the currently selected
    Route
    from the
    ApplicationCall
    ?
    d
    c
    • 3
    • 17
  • o

    orangy

    08/15/2018, 8:04 PM
    However, TBH, I think there is no test for some of these cases, so I’m not sure if it works as it should 🙂
    n
    • 2
    • 2
  • a

    alex009

    08/16/2018, 12:13 AM
    Hello. Anybody use ktor client with Json feature in multiplatform project (Android & iOS)? On Android no problems, but iOS can't parse object to Json automatically and fail with PipelineFailed...
    e
    • 2
    • 4
  • v

    vincent.brule

    08/16/2018, 7:07 AM
    Hello, I have this exception but the server doesn’t crash and the sessions works well. java.lang.IllegalStateException: Sessions feature should be installed to use sessions. Do you have an idea why please ?
    ✅ 1
    d
    • 2
    • 75
  • d

    dave08

    08/16/2018, 10:36 AM
    When Ktor starts up, I get this error, where could this be coming from? Is it from the server, or from my JsonRpc client (based on Ktor client)? It doesn't happen locally, only when in my Docker Swarm...
    -.kt
    d
    c
    • 3
    • 14
  • a

    Andrey Kormak [IceRock]

    08/19/2018, 1:53 PM
    Hello. Can anyone help me? I’am trying to do POST request by ktor Client in iOS app. But I cant set params. See my code above:
    -.txt
    👆 1
    e
    • 2
    • 2
  • v

    vincent.brule

    08/20/2018, 7:44 AM
    Hello, is it possible to send an email using ktor please ?
    ✅ 1
    d
    d
    • 3
    • 3
  • a

    alex009

    08/20/2018, 8:27 AM
    if i send request with body parsed from object via KotlinxSerializer i get incorrect request body (should be json content-type, but really is form-data) what may be reason of this?
    d
    a
    • 3
    • 50
  • a

    aeruhxi

    08/20/2018, 9:14 AM
    How do I serialize
    DefaultWebSocketServerSession
    ?
    d
    • 2
    • 12
  • v

    vincent.brule

    08/20/2018, 1:32 PM
    Hello, I don’t understand how to receive query parameter. I saw in the documentation : https://ktor.io/features/routing.html use param(name) but do you have an example please ?
    ✅ 1
    d
    • 2
    • 5
  • m

    Mohit Gurumukhani

    08/20/2018, 8:28 PM
    When using Json-feature in ktor-client to perform requests, we can do something like:
    val response = client.get<MyClass>(“<https://en.wikipedia.org/wiki/Main_Page”>)
    This will return convert the returned Json to MyClass. However, this won’t allow us to get additional info such as return status code etc. Is there a way to get around this?
    d
    g
    e
    • 4
    • 6
  • g

    gildor

    08/21/2018, 9:48 AM
    I’m not familiar with ktor-client, but maybe you can do something like:
    client.get<Response<MyClass>>(…) or client.getResponse<MyClass>(...)
    m
    • 2
    • 2
  • m

    Mohit Gurumukhani

    08/21/2018, 6:47 PM
    Hey! I am using Apache http client in jvm module and am getting No field instance of type Lorg/apache/http/message/BasicLineFormatter. However, if use the android client in the http module, then the error vanishes. Is using android client in jvm module feasible?
    e
    • 2
    • 18
  • b

    bffcorreia

    08/22/2018, 2:00 PM
    Hello! I’m building a multiplatform project and I’m using the ktor client in order to make the http requests. By looking at the client-mpp in the ktor samples, I was able to create a common client for the android and ios apps but my question is: there’s still no support for the JS client, right?
    e
    • 2
    • 14
  • s

    Semigradsky

    08/22/2018, 2:34 PM
    Where can I find documentation for the
    0.9.4
    version?
    c
    d
    • 3
    • 7
  • n

    nekoinemo

    08/22/2018, 3:04 PM
    Hi. Speaking of Multipart: do i need to manually dispose of every part? Or is it automatically disposed when call it is associated with completes?
    c
    • 2
    • 2
  • h

    Hamza

    08/22/2018, 3:27 PM
    hi guys, when u create a new ktor project with the plugin, it initialises stuff via a
    application.conf
    file. just curious, how does that work?
    c
    r
    • 3
    • 3
  • e

    enleur

    08/24/2018, 11:08 AM
    is it ok to use ktor as a reverse proxy for static content? any drawbacks?
    d
    • 2
    • 14
  • v

    Vinicius Carvalho

    08/24/2018, 12:00 PM
    Hi all, is it possible to detect if a websocket session was closed by the client? I'm getting some weird errors when a client closes the connection by leaving the page.
    d
    • 2
    • 18
  • v

    vincent.brule

    08/24/2018, 12:27 PM
    Hello, question about HttpsRedirect feature. I just install it and all my tests are failed now because handleRequest call are made with http so the request is redirected. Is it possible to have directly https call in handleRequest please ?
    ✅ 1
    d
    • 2
    • 28
  • o

    orangy

    08/26/2018, 12:11 PM
    I’d use
    varargs
    may be to avoid
    listOf
    on a call site
    a
    • 2
    • 1
  • o

    orangy

    08/26/2018, 1:17 PM
    Please tell me back if proposed solution works for you.
    👌 1
    • 1
    • 1
  • e

    enleur

    08/27/2018, 11:27 AM
    sorry for the repeat, but still actual 😊
    📝 1
    d
    e
    • 3
    • 23
Powered by Linen
Title
e

enleur

08/27/2018, 11:27 AM
sorry for the repeat, but still actual 😊
📝 1
d

Deactivated User

08/27/2018, 11:32 AM
val MyAttributeKey = AttributeKey<Int>("MyAttributeKey")
call.attributes.put(MyAttributeKey, 10)
call.attributes.get(MyAttributeKey)
The
ApplicationCall
contains a
attributes
property that acts as a small typed dependency injector/instance container bounded to the call (so its lifespan is between the request until the response is completed). You can put any attribute you want in an interceptor that executes before, and then receive it later in another interceptor
I have updated the documentation to explain this in detail: https://ktor.io/advanced/pipeline/attributes.html Let me know if it works for you
e

enleur

08/27/2018, 12:08 PM
Isn’t
HttpClientCall
used for ktor client?
I found only
HttpRequestBuilder.setAttributes
, but not sure if it works at all
something like this
install("MyFeature") {
    sendPipeline.intercept(HttpSendPipeline.Before) {
        this.context.setAttributes { 
            put(key, 1)
        }
    }
}
d

Deactivated User

08/27/2018, 12:13 PM
sorry, didn’t read the client part. I guess the client also has an
attributes
property, but let me check
yes, I think that’s what you have to use
the
HttpRequest
interface also has an attributes
So maybe
call.request.attributes
?
e

enleur

08/27/2018, 12:34 PM
not sure how can i get it inside
sendPipeline
or
requestPipeline
d

Deactivated User

08/27/2018, 12:34 PM
let me check
e

enleur

08/27/2018, 12:37 PM
PipelineContext<Any, RequestBuilder>
is used inside interceptors so i can use
HttpRequestBuilder
but don’t see any way to get to the
HttpRequest
it works inside
receivePipeline
tho
ok, let me explain what I want to do with this, may be I’m digging in the wrong way
d

Deactivated User

08/27/2018, 12:38 PM
@e5l
it looks that you cannot access an attributes directly there, not sure if it has an specific reason, so let’s wait for a response
e

enleur

08/27/2018, 12:41 PM
I want to pass extra info on call, like method name. Also I want to record time that was spent during request, I do this by wrapping
process()
with before/after timestamps. And in the end log all this data with extra info, passed in the beginning and total time
e

e5l

08/27/2018, 12:42 PM
Could you use
HttpRequestBuilder.setAttribute
to mark the request? You could get request from the response using
call
field.
e

enleur

08/27/2018, 12:49 PM
I tried to use
setAttribute
but it was never called how can i get
call
field inside
requestPipeline
?
receivePipeline.intercept(HttpReceivePipeline.Before) {
                println(context.request.attributes.takeOrNull(key))
            }
I also tried this, but it’s still empty and
setAttribute
was not called
e

e5l

08/27/2018, 12:51 PM
Oh, I see. It's obvious a bug. I'll file an issue and fix it asap.
👍 1
e

enleur

08/27/2018, 12:55 PM
Thanks!
View count: 6