mazorius
12/09/2020, 10:28 PMHttpClient().use {
GlobalScope.launch {
it.submitFormWithBinaryData {
url {
url(artifactRepository.get().baseUrl.clone().build())
parameter("repository", repositoryName.get())
headers {
append("User-Agent", System.getProperty("os.name"))
}
}
}
}
}
Unfortunately this ends up in the second run with io.ktor.client.engine.ClientEngineClosedException: Client already closed
Anyone an idea how I can handle this?Shreyas Patil
12/10/2020, 11:42 AMchristophsturm
12/10/2020, 3:56 PMchristophsturm
12/10/2020, 4:32 PMEvan
12/10/2020, 7:34 PMapplication/json
and the KotlinX serializer / JsonFeature, except for one.
On one endpoint, I have to upload file content with a multipart/form-data
request, that expects an application/json
response.
When I try to set the header on that request, it gives an error that the ktor engine is supposed to control the content type. Is there a way to override that behavior, or will I have to create a new HttpClient without the JsonFeature installed?Nikky
12/11/2020, 11:53 AMJson(Json.Default) { /*config here*/ }
bod
12/11/2020, 3:27 PMFrozen during lazy computation
when using by lazy
and InvalidMutabilityException: mutation attempt of frozen (my class)
when not.
I must admit I still haven't understood what "frozen" mean...
All works well with the same code on the JVM.
Am I the only one?Arkangel
12/11/2020, 5:28 PMFuelManager.instance.addRequestInterceptor(tokenInterceptor())
fun tokenInterceptor() = {
next: (Request) -> Request ->
{ req: Request ->
req.header(mapOf("Authorization" to "Bearer AbCdEf123456"))
next(req)
}
}
tieskedh
12/14/2020, 1:26 PMczuckie
12/16/2020, 4:23 PMAndrey Nikanorov
12/17/2020, 2:51 PMHttpResponseValidator
does not work on JS target for me. Any ideas? validateResponse
is not called at all.
Everything works as expected on Android (the same code). Bug or I miss something? 1.4.2Peter Ertl
12/17/2020, 3:45 PMMd Hanif
12/18/2020, 2:12 PMreified
and it seems to work fine with android
but throws an error in iOS
This is my common api call return in Shared file.
@Throws(Exception::class)
suspend inline fun<reified T> post(url: String, requestBody: HashMap<String, Any>?) : Either<CustomException, T> {
try {
val response = <http://httpClient.post|httpClient.post><T> {
url(BASE_URL.plus(url))
contentType(ContentType.Any)
if (requestBody != null) {
body = requestBody
}
headers.remove("Content-Type")
headers {
append("Content-Type", "application/json")
append("Accept", "application/json")
append("Time-Zone", "+05:30")
append("App-Version", "1.0.0(0)")
append("Device-Type", "0")
}
}
return Success(response)
} catch(e: Exception) {
return Failure(e as CustomException)
}
}
It works good in android if I call it like this :-
<http://api.post|api.post><MyDataClassHere>(url = "url", getBody()).fold(
{
handleError(it)
},
{
Log.d("Success", it.toString())
}
)
But I am not able to get it run on iOS devices it shows me error like this :-
`some : Error Domain=KotlinException Code=0 "unsupported call of reified inlined function `com.example.myapplication.shared.apicalls.SpaceXApi.post`" UserInfo={NSLocalizedDescription=unsupported call of reified inlined function <http://com.example.myapplication.shared.apicalls.SpaceXApi.post|com.example.myapplication.shared.apicalls.SpaceXApi.post>
, KotlinException=kotlin.IllegalStateException: unsupported call of reified inlined function <http://com.example.myapplication.shared.apicalls.SpaceXApi.post|com.example.myapplication.shared.apicalls.SpaceXApi.post>
, KotlinExceptionOrigin=}`
Any help in this is appreciated. ThanksIvan
12/21/2020, 11:25 AMrsetkus
12/21/2020, 9:23 PMhhariri
Justin Moy
12/22/2020, 8:19 PMRobert Jaros
12/23/2020, 1:27 AMMarc Knaup
12/23/2020, 3:17 PMclose()
an HttpClient
?
Why isn’t it designed so that the HttpClient
is bound to a CoroutineScope
and automatically closes when the scope is canceled/completed?
Isn’t this breaking structured concurrency (or at least requires workarounds)?n8ebel
12/23/2020, 9:06 PMapplication.conf
file by setting development=true
.
And by adding -Dio.ktor.development=true
to VM options in the IntelliJ run configuration
But no luck from the command line so far.Hamza
12/24/2020, 12:25 PMJgafner
12/25/2020, 12:43 PMMatthieu Stombellini
01/03/2021, 12:04 AMremoteHost
value, but it looks like it's hardcoded in TestApplicationRequest.local
. How can I set it to a custom value? The technique ForwardedHeaderSupport
uses to have a mutable version of RequestConnectionPoint
is internal
I also can't use the already existing MutableOriginConnectionPoint, as it's deprecatedRoman Vasilyev
01/03/2021, 9:29 PMtieskedh
01/04/2021, 10:22 AMmaxmello
01/05/2021, 5:39 PMroute("/resource") {
get("/") {
...
If i call GET /resource/, I get a not found. /resource works
route("/resource/") {
get {
...
In this case, GET /resource/ is found, but /resource not (expected behavior)
Is this intended behavior, a bug, or am I missing something?Roman Vasilyev
01/06/2021, 5:52 AMexpectSuccess
stopped working, 1.4.3 triggered validateResponse
on 404 e.t.c, now not:
fun HttpClientConfig<*>.myInit() {
expectSuccess = false
addMyValidator()
}
fun HttpClientConfig<*>.addMyValidator() {
HttpResponseValidator {
validateResponse { response ->
}
}
}
jozefdransfield
01/06/2021, 11:09 AMigor.wojda
01/06/2021, 1:09 PMtim
01/06/2021, 5:06 PMsuspend fun connect(host: String, path: String): DefaultClientWebSocketSession {
val client = HttpClient { install(WebSockets) }
println("I execute")
val session = client.webSocketSession {
url("wss", port = 443, host = host, path = path)
println("I execute")
}
println("I don't execute")
return session
}
}
Any thoughts?