Я использовал двигатель KTOR CIO для выполнения вызовов API. Когда я пытаюсь проверить сетевые вызовы, но URL -адреса не отображаются внутри Android Network Inspection. Команда тестирования производительности пыталась перехватить вызовы API с использованием инструмента Fiddler, но они также не могут захватить вызовы API.
< /code>
Я попытался добавить cleartexttrafficperted внутри файла AndroidManifest также для тестирования. Но, кажется, ничего не работает. Я что -нибудь упускаю здесь?@Provides
@Singleton
fun provideHttpClient(): HttpClient = HttpClient(CIO) {
expectSuccess = false
install(ContentNegotiation) {
gson()
}
install(Logging) {
logger = Logger.DEFAULT
level = LogLevel.ALL
}
install(HttpTimeout) {
requestTimeoutMillis = 120000
connectTimeoutMillis = 120000
socketTimeoutMillis = 120000
}
engine {
https {
trustManager = @SuppressLint("CustomX509TrustManager")
object : X509TrustManager {
@SuppressLint("TrustAllX509TrustManager")
override fun checkClientTrusted(p0: Array?, p1: String?) {
}
@SuppressLint("TrustAllX509TrustManager")
override fun checkServerTrusted(p0: Array?, p1: String?) {
}
override fun getAcceptedIssuers(): Array? = null
}
}
}
HttpResponseValidator {
validateResponse { response: HttpResponse ->
val statusCode = response.status.value
println("HTTP status: $statusCode")
when (statusCode) {
in 300..399 -> throw RedirectResponseException(response, statusCode.toString())
in 400..499 -> throw ClientRequestException(response, statusCode.toString())
in 500..599 -> throw ServerResponseException(response, statusCode.toString())
}
if (statusCode >= 600) {
throw ResponseException(response, statusCode.toString())
}
}
handleResponseExceptionWithRequest { cause, request ->
println("HTTP status: $cause")
throw cause
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/777 ... st-android