jkbbwr
01/24/2019, 12:34 AMctierney
01/24/2019, 3:36 PMDatabase
class is full of suspending functions (e.g. https://github.com/JetBrains/kotlinconf-app/blob/master/backend/src/org/jetbrains/kotlinconf/backend/database.kt#L42) that use a dedicated fixed threadpool context. I was wondering what the benefit of this style is? I would understand if the rest of the app called these functions using async
or something, but as they are all just called synchronously I’m wondering if writing them as suspending functions does anything particular. (Also, as they are not called asynchronously---how does that fixed thread pool actually get used?)functionaldude
01/24/2019, 8:03 PMparseUrlEncodedParameters(...)
is used to parse the form-url encoded data from the request body, but then I looked at the function source, the comment said Parse URL query parameters. Shouldn't be used for urlencoded forms because of "+" character.
I assume this function is only ment to be used on the actual URL parameter, but not on the body.
I also found a function parseQueryString(...)
which produces the correct result on the body.
Is this just an oversight in the docs, or am I missing something?cy
01/24/2019, 10:06 PMhost()
and port()
functions to respect proxy (#834)
* Fixed classloading issue affecting hot-reload (#825)
* Fixed hanging CIO client (#800, #806)
* Added CIO client CBC support (#623, #560, #394)
* Upgraded JWKS/JWT (#856)
* Fixed server MessageDigest
concurrent issues
* Introduced NonceManager
, deprecated OAuth2StateProvider
* Prohibited setting session at server after responding the call (#864)
* Fixed loosing errors in StatusPages
if there was already a response sent
* Introduced application
property on ApplicationEngine
interface
* Introduced experimental ktor server exceptions
* BadRequestException
* NotFoundException
* MissingRequestParameterException
* ParameterConversionException
* supported in locations out of the box (including #767)
* experimental parameters delegation support
* Added routing tailcard prefix support (#876, #526)
* Fixed registering content converters with custom content type pattern (#872)
* Improved GSON error diagnostics (#811)
* Exclude several content types in Compression feature by default: audio, video, event-stream (#817)
* Fixed hanging handleWebSocketConversation
* Fixed cookie session max-age value to be bumped to Int.MAX_VALUE (#892)
* Fixed CIO headers parsing: allowed headers with no values
* Fixed client websocket nonce size (#861)
* Fixed client scheme parsing
* Supported client relative redirects by making #takeFrom() resolve relative urls. (#849)
* Fixed network on main thread in CIO (#764)
* Changed the default algorithm to SHA-256 from SHA-1 for signed server cookies
* Fixed conflicting WebSockets
and StatusPages
(#889)
* Update gradle to 4.10
* Kotlin 1.3.20, kotlinx.coroutines 1.1.1, kotlinx.serialization 0.10.0
Please note that you have to migrate to Gradle 4.10+ to use ktor with MPP (multiplatform projects) due to Gradle metadata version change.
https://ktor.io/quickstart/migration/1.1.2.htmlTalon
01/24/2019, 10:43 PMio.ktor.client.call.ReceivePipelineException: Fail to run receive pipeline
doesn't happen locally, I'm thinking maybe I need to configure the client differently or something timeout related?coletz
01/25/2019, 9:34 PMcodyoss
01/26/2019, 2:59 AMHttpStatusCode
? It seems like the code just constructs a new one one that matches the status Int
. I found this odd when I did a when
switch on the status from HttpResponse
and the status did not match HttpStatusCode.OK
.Saiedmomen
01/26/2019, 10:08 AMMockEngine
?galex
01/27/2019, 5:09 AMwollnyst
01/27/2019, 2:29 PMkotlinx.serialization.json.JsonObject
as body on a ktor-client?
The following calls fails with kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class kotlinx.serialization.json.JsonObject
kotlin
val client = HttpClient(OkHttp) {
install(JsonFeature) {
serializer = KotlinxSerializer(JSON.nonstrict)
}
}
<http://client.post|client.post><Unit>(url) {
body = json { "hello" to "world" }
}
jdiaz
01/27/2019, 6:44 PM[ RUN ] io.ktor.client.test.CurlEnginesTest.postTest
kotlin.AssertionError: Expected <HttpBinResponse(url=<http://httpbin.org/post>, args={}, headers={Content-Type=text/plain; charset=UTF-8, Accept=application/json, Content-Length=11, Connection=close, Host=<http://httpbin.org|httpbin.org>})>, actual <HttpBinResponse(url=<http://httpbin.org/post>, args={}, headers={Accept=application/json, Connection=close, Content-Length=11, Content-Type=text/plain; charset=UTF-8, Host=<http://httpbin.org|httpbin.org>, X-Imforwards=20})>.
Vinicius Carvalho
01/27/2019, 8:59 PMsuspend fun request(offset: Int, limit: Int, endpoint: String) : ApiResponse<List<Map<String,Any>>> {
val end = limit + offset
return retroClient.request(endpoint = endpoint, offset = offset, limit = limit).execute().body()!! //using retrofit, works
// internalClient.request {
// url(URL("$BASE_URL$endpoint?offset=$offset&limit=$limit&format=json&api_key=$API_KEY"))
// method = HttpMethod.Get
// headers {
// append("User-Agent" , "Ktor Apache Client")
// append("Content-Type", "application/json")
// }
// }
}
dave08
01/28/2019, 1:16 PMdave08
01/28/2019, 1:43 PMJsonFeature
for this?dave08
01/28/2019, 5:15 PMApplicationConfig
... it's really a bit verbose right now. Instead of:
val username = config.property("username").getString()
, it could be val username: String by config
!!!codyoss
01/28/2019, 9:34 PM@ConfigurationProperties
. I am looking for an easy way to bind a subset on my configuration file to an object. Anything besides me writing custom getters that have a reference to the Application.enviorment.config
?napperley
01/29/2019, 12:38 AMSantosh Astagi
01/29/2019, 1:50 AMAharon
01/29/2019, 7:20 AMGraeme
01/29/2019, 8:10 AM@ConfigurationProperties
which you can use in micronaut-ktor
https://github.com/micronaut-projects/micronaut-kotlinribesg
01/29/2019, 8:59 AMktor-client-cio
pure Kotlin or not? Can I use it in the common part of a MPP?Alan Pierri
01/30/2019, 2:09 PMSantosh Astagi
01/30/2019, 7:32 PMAlbert
01/30/2019, 8:14 PMembeddedServer(Netty, port = 0)
But I don't know where I can get the random port from. And the logs are showing it is listening on <http://0.0.0.0:0>
Louis Saglio
01/30/2019, 10:11 PMfun Application.bank() {
install(Authentication) {
form("form") {
challenge = FormAuthChallenge.Unauthorized
passwordParamName = "password"
userParamName = "username"
validate { credentials ->
println("Credentials : ${credentials.name}, ${credentials.password}")
when {
credentials.name == "John" && credentials.password == "pa$$w0rd" -> UserIdPrincipal("John")
else -> null
}
}
}
}
routing {
authenticate("form") {
route("account") {
post {
call.respond(HttpStatusCode.OK, "connected")
}
}
}
}
}
To access the route /account I send this HTTP request :
POST <http://0.0.0.0:8081/account?username=Louis&password=pass>
But this raises an exception : io.ktor.features.CannotTransformContentToTypeException: Cannot transform this request's content to class io.ktor.http.Parameters
So I guess I should not give credentials to the server via POST body.
I have tried sending credentials in JSON with ContentNegocition installed but I get a similar error.
If someone could help me ...
I will update the documentation once I know how it works.
Posted in #serverrrva
01/31/2019, 5:58 AMNettyApplicationEngine
, why does ktor run application code in a threadpool of its own?Kenneth
01/31/2019, 3:03 PMBrian Mahecha
01/31/2019, 4:12 PMjozefdransfield
01/31/2019, 4:27 PMmp
01/31/2019, 10:08 PM