mirror of
https://github.com/square/okhttp.git
synced 2025-07-29 17:41:17 +03:00
Idiomatic Kotlin for Response.kt
- define `@get:JvmName(...)` for the following vals in constructor instead of passing `builder: Builder`. - `request: Request` - `protocol: Protocol` - `message: String` - `code: Int` - `handshake: Handshake?` - `headers: Headers` - `body: ResponseBody?` - `networkResponse: Response?` - `cacheResponse: Response?` - `priorResponse: Response?` - `sentRequestAtMillis: Long` - `receivedResponseAtMillis: Long` - `exchange: Exchange?` - add `@Deprecated(...)` to the following functions. - `fun request(): Request` - `fun protocol(): Protocol` - `fun message(): String` - `fun code(): Int` - `fun handshake(): Handshake?` - `fun headers(): Headers` - `fun body(): ResponseBody?` - `fun networkResponse(): Response?` - `fun cacheResponse(): Response?` - `fun priorResponse(): Response?` - `fun sentRequestAtMillis(): Long` - `fun receivedResponseAtMillis(): Long` - `fun cacheControl(): CacheControl` - clean up code where `()`(parentheses) is unnecessarily used.
This commit is contained in:
@ -202,7 +202,7 @@ class DnsOverHttps internal constructor(builder: Builder) : Dns {
|
||||
|
||||
val cacheResponse = client.newCall(cacheRequest).execute()
|
||||
|
||||
if (cacheResponse.code() != 504) {
|
||||
if (cacheResponse.code != 504) {
|
||||
return cacheResponse
|
||||
}
|
||||
} catch (ioe: IOException) {
|
||||
@ -216,16 +216,16 @@ class DnsOverHttps internal constructor(builder: Builder) : Dns {
|
||||
|
||||
@Throws(Exception::class)
|
||||
private fun readResponse(hostname: String, response: Response): List<InetAddress> {
|
||||
if (response.cacheResponse() == null && response.protocol() !== Protocol.HTTP_2) {
|
||||
Platform.get().log(Platform.WARN, "Incorrect protocol: ${response.protocol()}", null)
|
||||
if (response.cacheResponse == null && response.protocol !== Protocol.HTTP_2) {
|
||||
Platform.get().log(Platform.WARN, "Incorrect protocol: ${response.protocol}", null)
|
||||
}
|
||||
|
||||
response.use {
|
||||
if (!response.isSuccessful) {
|
||||
throw IOException("response: " + response.code() + " " + response.message())
|
||||
throw IOException("response: " + response.code + " " + response.message)
|
||||
}
|
||||
|
||||
val body = response.body()
|
||||
val body = response.body
|
||||
|
||||
if (body!!.contentLength() > MAX_RESPONSE_SIZE) {
|
||||
throw IOException(
|
||||
|
Reference in New Issue
Block a user