Closed nbaklanov-issart closed 5 years ago
Hi @nbaklanov-issart. What client engine do you use?
(Some engines forces get
requests to be without any payload).
Hi, thank you for your answer. I don’t know how to get exact client engine. I am working on multi-platform project and import ktor like :
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
implementation("io.ktor:ktor-client:$ktor_version")
implementation("io.ktor:ktor-client-json:$ktor_version")
}
}
And looks like you right about forcing requests without payloads. I already contacted with our service developer and he confirmed what usually get requests don't use body and it was api mistake. They will change it.
So I guess it's not a bug of engine. Sorry.
Should I do anything with this request? Close or put some mark on it?
Nope. Let's keep it, probably we need an exception or at least a warning here
When you using HttpClient()
without engine argument, it uses service loader to find an engine from dependencies.
When you using
HttpClient()
without engine argument, it uses service loader to find an engine from dependencies.
I am creating HttpClient in this way:
protected val client = HttpClient {
expectSuccess = false
}
So, I guess, it uses engine from dependancies (I posted them before).
Could you also post platform-specific dependencies?
Could you also post platform-specific dependencies?
sourceSets { commonMain { dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib-common' implementation("io.ktor:ktor-client:$ktor_version") implementation("io.ktor:ktor-client-json:$ktor_version") } } commonTest { dependencies { implementation 'org.jetbrains.kotlin:kotlin-test-common' implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common' } } androidMain { dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib' implementation("io.ktor:ktor-client-android:$ktor_version") } } androidTest { dependencies { implementation 'org.jetbrains.kotlin:kotlin-test' implementation 'org.jetbrains.kotlin:kotlin-test-junit' } } iosMain { dependencies { implementation("io.ktor:ktor-client-ios:$ktor_version") } } iosTest { } }
Fixed in master
.
Ktor Version
ktor_version = 1.0.1
Ktor Engine Used(client or server and name)
Ktor Clients
JVM Version, Operating System and Relevant Context
Android API 22
Feedback
Hi, everyone, I have a simple request code :
It's get request. But when I call this function like this :
I will get response like : Request method POST not supported. And in proxy logs I see that ktor really sending POST. If I will remove body from request - ktor will send get, but server will not accept this because it's waiting parameters in body.