guenther
05/31/2019, 5:19 AMrapho
05/31/2019, 11:27 AMrobstoll
05/31/2019, 2:56 PMMichael Strasser
06/01/2019, 7:31 AMmantono
06/03/2019, 9:39 AMcall.respond(...)
. It seems that whenever I insert my feature to a PipelinePhase
it is either too early for the principal to have been processed (I can see for example that the Authorization
header is present, but principal
is null because it has not been set yet) or to late to make a response to the request. How do I solve this (in a good manner)?Andy Victors
06/03/2019, 10:59 AMBy default, Ktor HTTP client does follow redirections; this feature allows to follow Location redirects in a way that works with any HTTP engine.
vs
The iOS engine uses the asynchronous NSURLSession internally. And have no additional configuration.
What is right? I use followRedirects=false
in MPP common code and on android it works properly but obviously it still follows redirects on iOS. Any way possible to force ktor not to follow redirects on iOS?Andrew Gazelka
06/03/2019, 11:02 PM<http://httpClient.ws|httpClient.ws>(...)
does not propagate errors... is there any way to catch them?ribesg
06/05/2019, 8:27 AMribesg
06/05/2019, 8:58 AM<http://http.post|http.post>(url) {
body = EmptyContent
}
darkmoon_uk
06/06/2019, 10:04 PMHttpClient
that should be Json Encoded? Using iOS, if that matters, and I have the JsonFeature
installed... but I get kotlin.ClassCastException: example.model.Person cannot be cast to io.ktor.client.call.HttpClientCall
. Here's my code:
runBlocking {
val client = HttpClient()
val message = <http://client.post|client.post><Person> { //(path = "/path") {
url("<http://localhost:8080/path>")
contentType(ContentType.Application.Json)
body = Person("James", "Smith")
}
}
...Person
is @Serializable
, should I not be setting it to the body of the post request like this? I assumed that, being Any
, JsonFeature
would know how to handle this? Can't find an example or details in ktor documentation.oday
06/07/2019, 5:11 PMorangy
06/08/2019, 4:21 PMcall as? RoutingApplicationCall
. If it’s not null, you’re in a route handler (or interceptor) and you can get route from there. However, you need to place interceptor inside routing
for this to workdarkmoon_uk
06/09/2019, 1:30 AMkotlin.NoSuchElementException: List is empty
when initialising HttpClient
with JsonFeature
on iOS 🤔
Not sure what's going wrong here but I suspect I have the wrong dependencies for target iosMain
, being:
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-iosx64:$kotlin_coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$kotlin_serialization_version")
implementation("io.ktor:ktor-client-ios:$ktor_version")
implementation("io.ktor:ktor-client-json-iosx64:$ktor_version")
..it's hard to follow what the dependencies should be from Ktor documentation and examples. These don't seem to have kept pace with recent changes in meta-data driven identifiers and other refactoring.pawelbochenski
06/10/2019, 12:16 PMMarc Knaup
06/12/2019, 12:26 AMHttpClient
in a Worker
(background thread) on native 🙂Dico
06/12/2019, 5:46 AMguenther
06/14/2019, 9:10 AMtwisterrob
06/14/2019, 9:27 AMget
is deep in the DSL. I wonder what primitives you would suggest me to use to do the blocking.Andy Victors
06/14/2019, 1:31 PMinstall(HttpCookies) {
storage = AcceptAllCookiesStorage()
}
on client init?
Specifying this causes iOS MPP to crash, but I need cookies! ;/
P.S. Also I cannot extract it from headers directly 'cause it looks like ktor strips the "Set-Cookie" header before 😕darkmoon_uk
06/16/2019, 1:16 AMContentNegotiation
feature in the server to receive & send serialized (JSON encoded) objects?
If the expected, exact content type is specified on both server and receiver, I don't see why ContentNegotiation
needs to be a hard requirement - I thought this was only about dynamically negotiating a variable content & type at run-time?mbonnin
06/16/2019, 3:49 PMEvan Bennett
06/17/2019, 1:11 AMinstall(Sessions) {
val sessionCookieKey = io.ktor.util.hex(environment.config.property("ktor.session.cookie.key").getString())
fun configureCookie(): CookieSessionBuilder<*>.() -> Unit = {
cookie.duration = null
cookie.domain = null
cookie.path = "/"
cookie.secure = true
cookie.httpOnly = true
cookie.extensions["SameSite"] = "Strict"
transform(SessionTransportTransformerMessageAuthentication(sessionCookieKey))
}
cookie<my.type.UuidV4>("SESSION_UUID", configureCookie())
cookie<java.util.Locale>("LOCALE", configureCookie())
}
I am getting an exception when I make a request to the server. (Which I will post as a reply.)
After looking in to this for a while, it appears that the SessionSerializerReflection.properties
contains [var java.util.Locale.baseLocale: sun.util.locale.BaseLocale!, var java.util.Locale.localeExtensions: sun.util.locale.LocaleExtensions!, var java.util.Locale.hashCodeValue: <http://kotlin.Int|kotlin.Int>, var java.util.Locale.languageTag: kotlin.String!]
which are all private transient
members of the java.util.Locale
class.
Is this a bug, or should I be doing this differently?Edd
06/17/2019, 2:26 PMHttpClient
which executes a long request. This call is triggered via a post
route, which looks something like this:
val http = HttpClient(Apache)
routing {
post("/api/start-job") {
<http://http.post|http.post><String>("<http://url-to-long-request>")
call.respond(HttpStatusCode.Accepted, "job started")
}
}
Sending a request to this route results in having to wait quite as the client makes a heavy request (it starts a job on another service). I'd like to simply send the request to <http://url-to-long-request>
and immediately return the 202
with "job started"
message. I could achieve this using an Executor
and wrapping the <http://http.post|http.post>
call, however I feel like that is not the right way to do this. Any suggestions on this?tjohnn
06/17/2019, 7:34 PMvoben
06/17/2019, 7:39 PMcall
Darren Bell
06/17/2019, 11:23 PMList is empty.", cause_th0jdv$_0: null, name: "NoSuchElementException"
My gradle file has the following
compile ("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${LibraryVersions.kotlin_js_serialization_version}")
compile ("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${LibraryVersions.kotlin_js_serialization_version}")
compile ("io.ktor:ktor-client-core:${LibraryVersions.ktor_version}")
compile ("io.ktor:ktor-client-js:${LibraryVersions.ktor_version}")
compile ("io.ktor:ktor-client-json-js:${LibraryVersions.ktor_version}")
compile ("io.ktor:ktor-client-serialization-js:${LibraryVersions.ktor_version}")
compile ("io.ktor:ktor-client-auth-basic-js:${LibraryVersions.ktor_version}")
Has anyone managed to get this working?yshrsmz
06/18/2019, 10:54 AMinstall(HttpCookies) {
storage = CustomStorage()
}
above code does not work, as AcceptAllCookiesStorage
is provided as a default value for Config class.
https://kotlinlang.slack.com/archives/C0A974TJ9/p1560522327059700?thread_ts=1560519079.059100&cid=C0A974TJ9Johnroest
06/19/2019, 1:09 PMvngantk
06/20/2019, 12:51 AMtjohnn
06/20/2019, 11:19 AMtjohnn
06/20/2019, 11:19 AMcy
06/20/2019, 11:37 AMit
application.install(StatusPages) {
exception<NotImplementedError> { error ->
call.respondHtml(HttpStatusCode.NotImplemented) {
...
tjohnn
06/20/2019, 11:54 AM