forked from loafle/openapi-generator-original
committed by
GitHub
parent
ced31f49b3
commit
f35b132068
@@ -13,6 +13,7 @@ import io.ktor.client.request.request
|
||||
import io.ktor.client.request.setBody
|
||||
import io.ktor.client.statement.HttpResponse
|
||||
import io.ktor.http.contentType
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.HttpMethod
|
||||
import io.ktor.http.Parameters
|
||||
@@ -147,6 +148,9 @@ open class ApiClient(
|
||||
this.method = requestConfig.method.httpMethod
|
||||
headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
|
||||
if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH)) {
|
||||
val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
|
||||
?: ContentType.Application.Json)
|
||||
this.contentType(contentType)
|
||||
setBody(body)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user