优化:服务端应答HTTP Status 201-299时特殊处理(更新日志状态为成功) #234

This commit is contained in:
pppscn 2024-04-10 17:17:09 +08:00
parent 7e6499be1b
commit 01aeb8d698

View File

@ -13,6 +13,7 @@ import okhttp3.Interceptor
import okhttp3.Response
import java.util.concurrent.TimeUnit
@Suppress("PrivatePropertyName")
class NoContentInterceptor(private val logId: Long) : Interceptor {
private val TAG: String = NoContentInterceptor::class.java.simpleName
@ -20,8 +21,9 @@ class NoContentInterceptor(private val logId: Long) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val originalResponse = chain.proceed(chain.request())
if (originalResponse.code() == 204) {
val response = "HTTP 204 No Content"
//HTTP Status 201-299 都算成功
if (originalResponse.code() in 201..299) {
val response = "HTTP Status " + originalResponse.code() + " " + originalResponse.message()
Log.d(TAG, response)
/*
// 创建一个空的响应体