Goku
04/13/2021, 12:25 PM<https://api.github.com/projects/columns/42>
in order to receive 401, which is intended.
Unfortunately, the program crashes with the following explanation:
Exception doesn't match @Throws-specified class list and thus isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: io.ktor.client.features.ClientRequestException: Client request(<https://api.github.com/projects/columns/42>) invalid: 401 Unauthorized. Text: "{"message":"Requires authentication","documentation_url":"<https://docs.github.com/rest/reference/projects#get-a-project-column>"}"
I get back the response and everything gets logged properly.
Any idea on how to fix this?
Thanks!Renaud
04/13/2021, 3:52 PMPablo
04/13/2021, 6:44 PMbuildHeaders { append("foo","bar" }
but looks like is not working if I add them in the request
it works...
it's weird.
httpClient.get<FooResponse>("<https://foo.bar>"){header("foo","bar")} <-- it works
Any idea why?Pablo
04/14/2021, 6:20 PMget
inside a
return HttpClient(OkHttp) {
//For instance if I want to update a refreshToken
}
christophsturm
04/14/2021, 9:08 PMval context = describe("ktor") {
it("routing works") {
val server = TestApplicationEngine(environment = createTestEnvironment {
module {
routing {
route("/x") {
route("/y") {
get {}
}
}
}
}
}) {}.apply { start() }
expectThat(server.handleRequest(HttpMethod.Get, "/x/y").response.status()).isNotNull().get { isSuccess() }.isTrue()
}
}
Justin Moy
04/14/2021, 9:26 PMrequest.cookies[]
, anyone have any idea why? setup in threadOsmium
04/15/2021, 6:19 AMNikolay Kasyanov
04/15/2021, 2:32 PMHttpClient
instance,
by using Reaktive helpers to “convert” coroutines into Observable
(or other Reaktive types).
To do actual asserts, Reaktive helpers like TestObserver
are used:
fun `it does whatever a spider cat does`() {
// ktorMockServerManager is just a way to configure mock engine handlers
ktorMockServerManager.enqueueRequest(
...
)
sut.doApiStuff(...)
.test()
.assertComplete()
}
The tests are completely synchronous, but as soon as I update ktor to 1.5.1 (1.5.0 is fine, though), they start failing because by the time assertComplete
is called, the underlying coroutine hasn’t yet finished, so the tests fail. If I add a sleep
call like this:
fun `it does whatever a spider cat does`() {
ktorMockServerManager.enqueueRequest(
...
)
val observer = sut.doApiStuff(...)
.test()
sleep(1000)
observer.assertComplete()
}
I wonder what change between 1.4.3 and 1.5.1 could lead to this and what’s the way around it?MarkRS
04/16/2021, 12:11 PMFi5t
04/16/2021, 4:17 PMGuilherme Delgado
04/17/2021, 9:42 AMlocal.properties
? This was my idea:
private fun getSecret(envKey: String, localKey: String): String = System.getenv(envKey) ?: ...(localKey,"")
Thanks!Pablo
04/17/2021, 12:17 PMHttpClientConfig<OkHttpConfig>
? I need to refresh my credentials on my server if I get a 401natario1
04/18/2021, 2:47 PMinstall { }
DSL is called, but the lambda passed to it is not. So that WebSocketExtensionFactory.install()
is never called, and even the outer WebSocketExtensionsConfig.build()
is never called.andrewreitz
04/18/2021, 11:01 PMxxfast
04/19/2021, 5:15 AMktor-client
in Android, and running into this error whenever i’m trying to make any request
kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for AwaitContinuation(DispatchedContinuation[Dispatchers.Main.immediate, Continuation at kotlinx.coroutines.DeferredCoroutine.await$suspendImpl(Builders.common.kt:101)@fcc4908]){Cancelled}@c6bb8a1.
...
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:465)
...
Caused by: java.lang.ClassCastException: kotlin.coroutines.jvm.internal.CompletedContinuation cannot be cast to kotlinx.coroutines.internal.DispatchedContinuation
...
at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(SuspendFunctionGun.kt:15)
Anyone got any clue as to what i’m doing wrong? I’m using Ktor 1.5.2
, with Android engine - along with kotlin 1.4.30
Nikolay Kasyanov
04/19/2021, 8:52 AMdave08
04/19/2021, 3:34 PMprivate fun ContentType.full() = "$contentType/$contentSubtype"
handleRequest(
<http://HttpMethod.Post|HttpMethod.Post>, "/some-url") {
addHeader(HttpHeaders.Accept, ContentType.Text.Plain.full())
}
landon burch
04/19/2021, 8:39 PMJoost Klitsie
04/19/2021, 10:18 PMDominick
04/20/2021, 5:53 PMstefandekanski
04/21/2021, 11:45 AMHttpClient.request
will throw IOException
for IO errors… ?Guilherme Delgado
04/21/2021, 8:20 PM//client
HttpClient(Apache) {
install(JsonFeature) { serializer = KotlinxSerializer(Json { ignoreUnknownKeys = true }) }
}
//server
install(ContentNegotiation) {
kotlinx.serialization.json.Json { ignoreUnknownKeys = true }
// gson { setPrettyPrinting() }
}
and this is a sample request:
val response = client.get<List<Event>>("<http://localhost:8080>${application.locationToUrl(EventsApi())}") {
body = ...
contentType(ContentType.Application.Json)
}
and this is the output:
invalid: 415 Unsupported Media Type. Text: ""
But if I uncomment gson { setPrettyPrinting() }
it works…
Shouldn’t kotlinx.serialization.json.Json
be enough? 🤔Dominick
04/22/2021, 4:54 AMget("/api") {
call.respondText("works")
}
static {
resource("/", "public/index.html")
resource("*", "public/index.html")
resources("public")
}
Harry B
04/22/2021, 10:12 AMcoder82
04/22/2021, 10:16 AMdarkmoon_uk
04/22/2021, 1:46 PMRaed Ghazal
04/22/2021, 5:53 PMTim Malseed
04/23/2021, 12:38 AMlandon burch
04/23/2021, 5:00 PMwithTestApplication({ module() })
inside the module it setup database with url does doesn't point anywhere.. I wanted to know if anyone had experience with this. I am hoping to keep this a mock and not an in memory database..Alexander Black
04/23/2021, 6:00 PMAlexander Black
04/23/2021, 6:00 PMturansky
04/23/2021, 6:26 PMAlexander Black
04/23/2021, 6:56 PM