Alex Cruise
08/12/2022, 5:04 PMApplication
spierce7
08/12/2022, 8:07 PMAlper Tekin
08/13/2022, 11:40 AMmartmists
08/13/2022, 1:54 PMkotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class team.luminescent.site.auth.DiscordAuthPrincipal with modifiers "private final"
The DiscordAuthPrincipal is just an oauth principal:
data class DiscordAuthPrincipal(val accessToken: String, val refreshToken: String) : Principal {
fun isValid(): Boolean {
// Fetch API to do additional checks
}
}
Code:
exception<Exception> { call, err ->
call.respondTemplate(HttpStatusCode.InternalServerError, "pages/error/500", mapOf(
"error" to err.stackTraceToString()
))
}
martmists
08/13/2022, 5:27 PMHamza GATTAL
08/13/2022, 6:53 PMRajput Art Studio
08/14/2022, 5:29 AMTóth István Zoltán
08/16/2022, 4:06 AMstatic { ... }
?
What I would like to do:
• user A can access files from ./a
folder
• user B can access files from ./a
and ./b
folders
Authentication is done in a very different part of the application. I wouldn't touch that if there is a way. Actually, I shouldn't touch that as authentication and authorisation are two different topics.
As I see, my only option right now is to write (i.e. cut&paste from Ktor) my own handling of static resources and add the authorisation.
Are there any better options? Thanks in advance.Leon Kiefer
08/16/2022, 4:50 PMHttpClient.config
from another client B, or do I only need to close the client B?William Reed
08/16/2022, 6:27 PMRyan Brink
08/17/2022, 1:24 AMAnaniya
08/17/2022, 12:37 PMBufferedImage
over websocket efficiently
1 tried to deserilize the constructor using GSON because it has nested object resulting the https://stackoverflow.com/questions/43301580/gson-cant-serialize-bufferedimages
2 tried kotlinx serilization , doesn't work since BufferedImage
has no @Serilizable
annotation
3 tried converting buffered image -> float array -> to string(using joinToString) kind of worked but its super slow and unresponsive
4 tried converting buffered image -> bytearray using ByteArrayOutputStream
and ImageIO.write()
has made significant improvement but still unusable
I don't think the IO
method would be any efficient but if there's any way to send the whole BufferedImage
object or deserilizing it without using IO would be take less timeNiko
08/17/2022, 4:33 PMstatic {}
block that offers serving static files, but with my system markdown pages are lazily converted to HTML, cached and served.
I'm thinking how I could decouple deploying the service and the documents to allow more dynamic deploy and update of the actual documents. Currently the block resolves the files from classpath, but I was thinking additionally I could write logic to check a configurable path, to allow running the service inside container with mounted docs path. Other thing I thought was, if I could implement a way to deploy additional jar containing only the documents to same classpath the service runs in.
Any inside or pointers, in achieving any of the two, or another way?napperley
08/18/2022, 3:03 AMJerry Yion
08/18/2022, 6:40 AMddimitrov
08/18/2022, 3:20 PMfun testPostCustomer() = testApplication {
val client = createClient {
install(ContentNegotiation) {
json()
}
}
val response = <http://client.post|client.post>("/customer") {
contentType(ContentType.Application.Json)
setBody(Customer(3, "Jet", "Brains"))
}
assertEquals("Customer stored correctly", response.bodyAsText())
assertEquals(HttpStatusCode.Created, response.status)
}
I find that to be broken, as the closure argument of the test application configures the application builder, and executing the stimuli and the assertions mean that you are running these from your app config code before the app is started. I am not even sure how it ever works, even if sometimes it does.
In my case, my app is starting an event pump for external Java API (think TIBCO RV) from the ApplicationStarted event, and this callback is invoked at the end of the test, after all assertions have failed (I found that only after commenting out a lot of code).
Raised: https://youtrack.jetbrains.com/issue/KTOR-4773ddimitrov
08/18/2022, 3:45 PMbbaldino
08/19/2022, 5:10 PMJoe Altidore
08/19/2022, 10:19 PMzt
08/22/2022, 12:32 AM<https://www.youtube.com>
, using some other url like <https://www.github.com>
works fine with both CIO and Android.
HttpClient(CIO).get("<https://youtube.com>")
java.net.SocketException: Network is unreachable
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:762)
at io.ktor.network.sockets.SocketImpl.connect$ktor_network(SocketImpl.kt:50)
at io.ktor.network.sockets.SocketImpl$connect$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:67
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
fair_enough
08/22/2022, 11:19 AMinstall(Sessions) {
cookie<RegularUserSession>("regular_user_session", SessionStorageMemory())
cookie<GoogleUserSession>("google_user_session", SessionStorageMemory())
}
install(CORS) {
allowHeader("regular_user_session")
exposeHeader("regular_user_session")
allowHeader("google_user_session")
exposeHeader("google_user_session")
allowMethod(HttpMethod.Options)
allowMethod(HttpMethod.Put)
allowMethod(HttpMethod.Delete)
allowMethod(HttpMethod.Patch)
allowHeader(HttpHeaders.Authorization)
allowHeader(HttpHeaders.AccessControlAllowOrigin)
allowNonSimpleContentTypes = true
allowSameOrigin = true
anyHost()
}
tried allowHeader only or exposeHeader only or both
HttpClient(engineFactory) {
install(HttpCookies)
}
On same host client:
1. Connection: keep-alive
2. Content-Encoding: deflate
3. Content-Type: application/json
4. Set-Cookie: regular_user_session=75f7618f14d56eaa81f04b0564146e4d; Max-Age=604800; Expires=Mon, 29 Aug 2022 111024 GMT; Path=/; HttpOnly; $x-enc=URI_ENCODING
5. transfer-encoding: chunked
On COSRS client:
1. Access-Control-Allow-Origin: *
2. Access-Control-Expose-Headers: google_user_session, regular_user_session
3. Connection: keep-alive
4. Content-Encoding: deflate
5. Content-Type: application/json
6. Set-Cookie: regular_user_session=a848eb176774abd4ded030892bc5615f; Max-Age=604800; Expires=Mon, 29 Aug 2022 110931 GMT; Path=/; HttpOnly; $x-enc=URI_ENCODING
7. transfer-encoding: chunked
But it still doesn't works on CORS client. I dont know whyAugust Lilleaas
08/22/2022, 11:21 AMApplicationRequest.javaSecurityPrincipal
, in io/ktor/server/servlet/JAASBridge.kt
which checks if the request is ServletApplicationRequest
. As far as I can tell, this never works, since the request is always a RoutingApplicationRequest
that delegates to the original request in io/ktor/server/routing/RoutingApplicationCall.kt
- i.e. the is
check doesn’t find the ServletApplicationRequest
instance, just the RoutingApplicationRequest
, as is
does not check for delegates (?). Is this a bug? Or is there some other way to access the principal on the servlet request from Ktor?amadeu01
08/23/2022, 8:55 AMfair_enough
08/24/2022, 4:18 PMAccept-Encoding: gzip, deflate, br
and I am receiving br. But, when I am accessing same server from LAN ip or domain, browser set only Accept-Encoding: gzip, deflate
, so I get only gzip. Any ideas?KamilH
08/25/2022, 6:17 AMkevin.cianfarini
08/25/2022, 1:01 PM2.0.3
with cURL on K/N with the new memory manager on linuxX64
. It always happens on the second network request for a given "service". Here's an abbreviated stracktrace.
Uncaught Kotlin exception: kotlinx.coroutines.JobCancellationException: Parent job is Completed; job=JobImpl{Completed}@162aaa80
at 0 permit-data.kexe 0x42fd70 kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 128
at 1 permit-data.kexe 0x42ff20 kfun:kotlin.RuntimeException#<init>(kotlin.String?;kotlin.Throwable?){} + 128
at 2 permit-data.kexe 0x4304a0 kfun:kotlin.IllegalStateException#<init>(kotlin.String?;kotlin.Throwable?){} + 128
at 3 permit-data.kexe 0x43bf30 kfun:kotlin.coroutines.cancellation.CancellationException#<init>(kotlin.String?;kotlin.Throwable?){} + 128
Full stacktrace is in thread. I'm going to keep digging in, Is this perhaps a problems with ktor client?Trey
08/25/2022, 4:24 PMBrent Beardsley
08/25/2022, 4:29 PMOkHttp
ktor client in a testApplication
block? We're seeing channel closed issues with the default client and was trying to work around it.Raymond Zeng
08/26/2022, 1:00 AMMing Chun Or
08/26/2022, 3:54 AMonDwonload
hook but it seems didn’t help. The response.bodyAsChannel()
seems to be returning the whole response (buffered into memory?) before I can check and consume it. I want to cut the underlying HTTP call early if the response size is too large.