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

    uli

    12/18/2022, 9:08 PM
    Hi there, is there a way to make ktor on kotlin-native stop on sigterm? I already
    addShutdownHook
    as suggested for java:
    applicationEngine.addShutdownHook {
            println("Shutdown hook received")
            println("Stopping engine")
            applicationEngine.stop(200, 500)
            println("Engine stopped")
        }
        applicationEngine.start(wait = true)
    a
    s
    • 3
    • 4
  • n

    Norbi

    12/19/2022, 5:24 PM
    I would like to GET an XML document from a HTTP server where the content type is set erroneously to 'xml'.
    HttpClient
    throws
    BadContentTypeFormatException
    , is there any way to work around it?
    a
    • 2
    • 3
  • s

    Slackbot

    12/21/2022, 1:08 PM
    This message was deleted.
    l
    • 2
    • 1
  • a

    Alex Cruise

    12/21/2022, 10:25 PM
    hey folks, I couldn’t find info about this in the docs, but I’m implementing an API that’s semi-async, i.e. the client can specify that if the request completes within a particular timeout, the server can respond synchronously (i.e. the response to the “submit” request contains the content), or if it’s going to take longer than that, the server should continue processing the request in the background and return an ID that the client can poll on later… 🧵
    e
    • 2
    • 3
  • z

    Zea

    12/22/2022, 2:29 AM
    Hi guys, I was wondering whether it is possible to create a full yet simple website (Such as Blog or Portfolio) using Ktor? I mean, most of tutorial out there only highlight REST API and such... Can I use something like ORM or Templating Engine? Thanks!
    a
    s
    • 3
    • 5
  • s

    Serafeim Papastefanos

    12/22/2022, 9:59 AM
    Hello friends! I've observed that when I press ctrl+c to stop a ktor application from running it takes a little while until it stops.Do you know why? Is there a way to make it instant ? Also the same is true when I start/restart an application from intellij idea: I press the stop button and it takes some seconds until it really stops
    c
    a
    • 3
    • 11
  • s

    Serafeim Papastefanos

    12/22/2022, 10:40 AM
    I'm trying to configure a ktor application using the configuration file, as described here: https://ktor.io/docs/configurations.html#configuration-file ... I've put a file on my
    src/main/resources/application.conf
    and works great. However, to deploy the app I create a fat jar. Is there a way to override some configuration options when I deploy that fat jar ? I know that I can use env vars but there are too many options that would need overriding. is it possible to pass another configuration file to the fatjar that would be used to override configuration options ? i.e run it like
    java -jar ktor-fat.jar -c local.conf
    ; when trying to read a configuration value, it will first check
    local.conf
    , if not found then go to
    resources/application.conf
    inside the jar
    a
    l
    • 3
    • 7
  • e

    Edoardo Maria Liotta

    12/22/2022, 3:33 PM
    ciao! we stumbled upon an issue using Auth plugin and AWS API Gateway. Trying to summarize, when a request with an invalid token is performed towards a auth-protected Gateway endpoint, a 401 response is provided, along with the following www-authenticate header:
    www-authenticate: Bearer scope="" error="invalid_token" error_description="token contains an invalid number of segments"
    but according to the Auth parser, this header is malformed (see stacktrace below). In the end, this causes refresh tokens never to be requested. Can you confirm whether this issue is on the parser or on AWS? Thank you in advance Ktor and Auth plugin ver: 2.2.1
    io.ktor.http.parsing.ParseException: Expected delimiter , at position 16, but found e
    	at io.ktor.http.auth.HttpAuthHeaderKt.skipDelimiter(HttpAuthHeader.kt:441)
    	at io.ktor.http.auth.HttpAuthHeaderKt.matchParameters(HttpAuthHeader.kt:141)
    	at io.ktor.http.auth.HttpAuthHeaderKt.parseAuthorizationHeader(HttpAuthHeader.kt:106)
    	at io.ktor.http.auth.HttpAuthHeaderKt.parseAuthorizationHeaders(HttpAuthHeader.kt:69)
    	at io.ktor.client.plugins.auth.Auth$Plugin$install$2.invokeSuspend(Auth.kt:58)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    	at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:205)
    	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:135)
    	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:109)
    	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:11)
    	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:59)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    	at android.os.Handler.handleCallback(Handler.java:942)
    	at android.os.Handler.dispatchMessage(Handler.java:99)
    	at android.os.Looper.loopOnce(Looper.java:201)
    	at android.os.Looper.loop(Looper.java:288)
    	at android.app.ActivityThread.main(ActivityThread.java:7872)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
    a
    • 2
    • 6
  • a

    Andrey Tabakov

    12/22/2022, 4:00 PM
    how to config KtorSimpleLoggerJs ?
  • i

    Ivan Đorđević

    12/23/2022, 1:29 PM
    Is there no way to differentiate between different verification failures/exceptions whe ktor's jwt authentication? The challenge function only receives the application call in the context, no exception/cause 😕
    c
    • 2
    • 3
  • s

    Serafeim Papastefanos

    12/23/2022, 1:50 PM
    Is there any reason to use netty instead of jetty when I don't need to use web sockets?
    a
    • 2
    • 2
  • a

    Antonio Acuña Prieto

    12/23/2022, 5:58 PM
    Guys, I'm trying to use Auto-reload, I've configured it and it works executing run and build task in two terminals, is there any way to run these two tasks as one?
  • j

    jwperez84

    12/23/2022, 9:57 PM
    Hey everyone. Is there a way to trust a self signed cert in KMM, using KTOR and its Darwin engine on the iOS side?
    r
    • 2
    • 2
  • a

    Andrey Tabakov

    12/28/2022, 11:25 AM
    Hello, is there a way to rename default java process (java.exe -> myktorjava.exe) using
    Gradle Application plugin
    ?
  • b

    Benoît Liessens

    12/28/2022, 11:59 AM
    You are running gradle inside the container so it is downloading all dependencies to build everything. Could take a little longer than you’ld except. Are you sure it freezes?
    a
    • 2
    • 1
  • a

    Aminu Babayo Shehu

    12/28/2022, 10:02 PM
    Hello I’m trying to deploy my ktor app to docker using below FROM gradle:7-jdk11 AS build COPY --chown=gradle:gradle . /home/gradle/src WORKDIR /home/gradle/src RUN gradle buildFatJar --no-daemon FROM openjdk:11 EXPOSE 7000:7000 RUN mkdir /app COPY --from=build /home/gradle/src/build/libs/*.jar /app/web-agent.jar ENTRYPOINT [“java”,“-jar”,“/app/web-agent.jar”]
  • a

    Aminu Babayo Shehu

    12/28/2022, 10:04 PM
    Hello I’m trying to deploy my ktor app to
    Docker
    using this
    Dockerfile
    p
    h
    d
    • 4
    • 8
  • a

    Aminu Babayo Shehu

    12/29/2022, 8:39 AM
    Please help how can I use docker with postgres db?
    k
    • 2
    • 17
  • a

    Aminu Babayo Shehu

    12/29/2022, 1:20 PM
    Help please file read/write not working when I deployed my ktor project to docker. I'm getting this error
    java.io.FileNotFoundException: uploads/QrsISelD9SS5yZmT1Yp9U03syK65g0.jpg (No such file or directory)
    for both read and write
    k
    • 2
    • 2
  • m

    Matti MK

    12/29/2022, 2:13 PM
    I’ve got an endpoint that returns valid JSON with
    Content-Type text/html; charset=UTF-8
    . The response is as follows
    { "result": [ "foo", "bar" ] }
    . When I try to serialize this into a POJO Ktor I get the following error:
    No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class FooList
    This is most certainly about the wrong
    Content-Type
    , but in this case I cannot change the server
  • m

    Matti MK

    12/29/2022, 2:16 PM
    I’ve got an endpoint that returns valid JSON with
    Content-Type text/html; charset=UTF-8
    . The response is as follows
    { "result": [ "foo", "bar" ] }
    . When I try to serialize this into a POJO Ktor I get the following error:
    No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class FooList
    This is most certainly about the wrong
    Content-Type
    , as with valid
    application/json
    header everything works as expected. Unfortunately, I cannot change the server’s headers. Is there a workaround for this on client side? I tried with
    accept(ContentType.Text.Plain)
    as well as
    accept(ContentType.Any)
    but those don’t really help.
    r
    • 2
    • 9
  • r

    rcd27

    12/30/2022, 3:16 PM
    Greetings. We are trying to write some tests for
    ktor
    with
    embeddedServer
    using
    mockk
    library. And we are facing some problems with mocking objects. What is the best way to test
    ktor
    application? Assuming we need to mock some stuff that goes to third-party services? Any tough samples? Thanks.
    c
    r
    • 3
    • 5
  • s

    Sam Gammon

    01/01/2023, 2:52 AM
    Hello :kotlin: friends, What if Node were more than just JS? To celebrate the new year, I am pleased to share a new project called Elide, a new server runtime, like Node or Deno, but polyglot, written in Kotlin and based on GraalVM. We are in alpha and very open to early feedback and contributions for anyone interested, over in #framework-elide 🥳 You can do wild things with it, like fast React SSR in Micronaut or Spring. Guest language support is starting with JS, but there are plans to integrate other languages like Python, Ruby, and Rust/Go/etc. via LLVM. Of course,
    native-image
    is supported out of the box. • 🚀 Trying it out
    curl -sSL --tlsv1.2 dl.elide.dev/cli/install.sh | bash -s -
    👆 the one liner works on Darwin (amd64/arm64), and Linux (amd64) so far.
    If you prefer NPX:
    npx @elide-dev/elide@alpha shell
    :kotlin-intensifies-purple: Building Kotlin apps with it • Elide can be used as a plain library with a regular Micronaut server, and Ktor support is on the way. There are Maven artifacts in a custom repository which is easy to use during the alpha; you can see a sample here. • :gradle: Gradle plugin You can easily install the Gradle plugin to build your frontend assets and your Kotlin/JS, and package it into your server binary. It will handle building for SSR and CSR both, so you can easily switch between browser rendering modes. Check it out here. Maven and Bazel support are planned. • 🖥️ Using the shell
    elide shell
    drops you into a shell just like Node (see attached screenshot), the difference being the
    URL
    class we're using here is implemented in Kotlin, backed by the road-tested power of Micronaut, KotlinX, Netty, and the Java standard library. It has simply been adapted for use in JavaScript, according to the WhatWG URL Spec. • :js: Use Kotlin/JS or regular Node stack Elide packages and consumes your JS/TS with built-in support for
    esbuild
    , so you can use a standard Node toolchain or the Kotlin/JS stack. • 💨 Super fast React SSR Because Elide is basically Kotlin with a super-fast JS runtime attached, it can do JS SSR without leaving the JVM. This can soon be drop-in compatible with many React apps. You can see a live sample here to confirm it is fast and server-rendered. The code for that sample is pasted below to show how simple it is to call back and forth between Kotlin and your React app:
    @Page class Index : PageWithProps<YourProps>(YourProps.serializer()) {
    
        // Serve React SSR.
        @Get("/") suspend fun indexPage(request: HttpRequest<*>) = ssr(request) {    // 1: tell the server we're going to do SSR for this request
          head {
            title { +"Hello, Elide!" }
            stylesheet("/styles/base.css")
            stylesheet("/styles/main.css")
            script("/scripts/ui.js", defer = true)   // <-- 2: serve the CSR bundle so it can hydrate the react SSR response
          }
          body {
            injectSSR(this@Index, request)    // <-- 3: execute the JS VM to produce the SSR response, and splice it into the server response
          }
        }
    
    }
    • 🐙 Contributors needed The future of software is much more polyglot than today's paradigm: developers love to fight about frameworks, but at the end of the day, we're all writing code, and eliminating barriers between languages means easier collaboration and more value for all of us. It shouldn't be a Node vs. The World or a Rust vs. The World argument; we should get to pick and pull the best code we want from anywhere and use it to build our apps, especially from a multi-platform language like Kotlin. This runtime and framework are designed for that future. *If you agree, join us and make a dent in the universe*; you'll have a chance to be impactful and shape a brave new idea from the ground up. • 🙏 Thank you We chose Kotlin because of the fantastic community. 2023 will be a massive year for Kotlin, and we think that betting the farm on it is reasonable and smart. We are super excited about what JetBrains and Kotlin have in store for us with K2, context receivers, value classes... just so much to look forward to. Cheers and happy new year, Kotlin devs, :kotlin-intensifies-purple: sam Posted in #feed
  • a

    Alexander Weickmann

    01/01/2023, 7:09 PM
    Hey all, i am using ktor-client with basic auth. depending on the situation, my backend needs to call the other rest endpoint with different users. is it possible to reuse the same http client and only provide the basic auth credentials on a call-by-call basis, instead of configuring it just once when creating the http client?
    d
    • 2
    • 2
  • t

    Tech

    01/01/2023, 11:09 PM
    With ktor-server-resources is it possible to automatically make all marked classes with
    Resource
    serializable?
    h
    r
    • 3
    • 7
  • t

    Tech

    01/02/2023, 1:53 PM
    With ktor rate limiting is it possible to ignore rate limiting for authorized requests and public ones get rate limited?
    r
    • 2
    • 3
  • c

    Christiano

    01/02/2023, 10:02 PM
    Hello! I have a question regarding the
    oauth
    functionality for ktor. Instead of using a third party provider (like Google, Github,... ) I would like to have everything on my own server. Is there any tutorial or guide to follow to set everything up? Is this even possible, because I can't seem to find anything about this... 😅
    a
    • 2
    • 1
  • a

    Andreas Scheja

    01/03/2023, 9:32 AM
    Hi, I was wondering if there is a special reason why the
    ResponseSent
    and
    ReceiveRequestBytes
    hooks don't have suspending handlers? At least the latter is given a
    ByteReadChannel
    so suspending calls should be quite common?
    a
    e
    • 3
    • 3
  • f

    Francisco Ripoli

    01/03/2023, 3:45 PM
    hello all! On my previous
    Spring
    projects, I had a separate maven project, just with a openapi yaml file, which I called the spec, and generated a jar file that would later be used on the actual service project, that way, both backend and fronted used that as a contract and we would not have issues with mismatching urls and request/response properties. I used to generate all that from my openapi yaml file using the openapi generator maven plugin … I’m trying to achieve something similar for
    ktor
    but it seems impossible. I’ve tried many combinations of the settings for the plugin, but no luck. Is anyone doing something similar?
    a
    • 2
    • 1
  • c

    CLOVIS

    01/03/2023, 7:20 PM
    What does this mean?
    TRACE i.k.s.p.c.ContentNegotiation - Skipping because the type is ignored.
    I'm using
    testApplication
    with just the
    ContentNegotiation
    plugin using KotlinX.Serialization
    e
    • 2
    • 26
Powered by Linen
Title
c

CLOVIS

01/03/2023, 7:20 PM
What does this mean?
TRACE i.k.s.p.c.ContentNegotiation - Skipping because the type is ignored.
I'm using
testApplication
with just the
ContentNegotiation
plugin using KotlinX.Serialization
e

e5l

01/03/2023, 7:25 PM
Hey @CLOVIS, thanks for the question. It means that body with that type is not usually handled with ContentNegotiation plugin(like
String
or
ByteReadChannel
). If you it's necessary you can remove the type from ignored: https://api.ktor.io/ktor-server/ktor-server-plugins/ktor-server-content-negotiatio[…]egotiation/-content-negotiation-config/remove-ignored-type.html
c

CLOVIS

01/03/2023, 7:27 PM
Strange. This is the type I'm serializing:
@Serializable
class New(
	val name: String,
)
Is it because it has a single String field? It's not a value class
e

e5l

01/03/2023, 7:28 PM
This type is not ignored by default
c

CLOVIS

01/03/2023, 7:29 PM
Is there an easy way to turn on additional logging to get more information on what's going on?
According the client logging, the entire request is:
METHOD: HttpMethod(value=POST)
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Authorization: Bearer fake:0
CONTENT HEADERS
-> Content-Length: 27
-> Content-Type: application/json
BODY Content-Type: application/json
BODY START
{"name":"A new department"}
BODY END
It's definitely sending my class, not just a primitive
e

e5l

01/03/2023, 7:35 PM
Yep, but this logging is for the request body
c

CLOVIS

01/03/2023, 7:35 PM
Oh. The client isn't logging anything for the response.
e

e5l

01/03/2023, 7:35 PM
Could you tell me how you're receving the response body?
c

CLOVIS

01/03/2023, 7:36 PM
Do you mean, the client-side code to deserialize?
e

e5l

01/03/2023, 7:36 PM
server side request handler
c

CLOVIS

01/03/2023, 7:38 PM
Using
call.receive()
: https://gitlab.com/opensavvy/pedestal/-/blob/main/spine-ktor/spine-ktor-server/src/commonMain/kotlin/opensavvy.spine.ktor.server/Server.kt#L90
Sorry, that's anything but a small example 😅
The type is not visible in this file because of generics, but it is the
New
class I shared above
I have used this exact function in other projects so I think it's unlikely that's where the problem is, I expect it's something to do with the
TestApplication
configuration, but I have no idea what it could be
e

e5l

01/03/2023, 7:43 PM
could you tell me how the
TestApplication
is configured?
c

CLOVIS

01/03/2023, 7:44 PM
It has the
Routing
,
ContentNegotiation
and
Authentication
plugins (don't hesitate to ask for the specific config for each, this project is FOSS) Specifically for ContentNegotiation:
val ApiJson = Json {
	encodeDefaults = false
}

install(ContentNegotiation) {
	json(ApiJson)
}
(this is Ktor 2.2.1 btw, I believe it's either the most recent version or close to it?)
e

e5l

01/03/2023, 7:45 PM
Could you log an issue with small repro? I will take a look
c

CLOVIS

01/03/2023, 8:04 PM
In the process in minifying it, I found something interesting: if I remove the
authenticate {}
block, it works
If you want to run it locally: • The repository is https://gitlab.com/opensavvy/formulaide • The problem can be reproduced on commit 80da9f76f5fd67114346adf8e9ea8b15ee86a56b • The reproduce, run
remote-server:test
, more precisely
opensavvy.formulaide.remote.server.utils.ReproductionTest
• As it is, the test returns a 400 Bad Request with no body • By disabling authentication (line 31), the test passes
Ah 😐 found the probkem
It's the
:
in:
-> Authorization: Bearer fake:0
I'm creating an issue to make it a better error message 🙂
https://youtrack.jetbrains.com/issue/KTOR-5409/The-error-message-is-not-helpful-when-authenticating-with-a-bearer-header-with-a-colon
View count: 65