mirror of
https://github.com/square/okhttp.git
synced 2025-08-07 12:42:57 +03:00
committed by
Jesse Wilson
parent
7337b1d7ac
commit
f468cfc7b2
@@ -241,7 +241,7 @@ class HttpLoggingInterceptor @JvmOverloads constructor(
|
|||||||
logger.log("<-- END HTTP (encoded body omitted)")
|
logger.log("<-- END HTTP (encoded body omitted)")
|
||||||
} else {
|
} else {
|
||||||
val source = responseBody.source()
|
val source = responseBody.source()
|
||||||
source.request(java.lang.Long.MAX_VALUE) // Buffer the entire body.
|
source.request(Long.MAX_VALUE) // Buffer the entire body.
|
||||||
var buffer = source.buffer
|
var buffer = source.buffer
|
||||||
|
|
||||||
var gzippedLength: Long? = null
|
var gzippedLength: Long? = null
|
||||||
|
@@ -246,3 +246,7 @@ fun ServerSocket?.closeQuietly() {
|
|||||||
fun isAndroidGetsocknameError(e: AssertionError): Boolean {
|
fun isAndroidGetsocknameError(e: AssertionError): Boolean {
|
||||||
return e.cause != null && e.message?.contains("getsockname failed") == true
|
return e.cause != null && e.message?.contains("getsockname failed") == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Long.toHexString() = java.lang.Long.toHexString(this)
|
||||||
|
|
||||||
|
fun Int.toHexString() = Integer.toHexString(this)
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
package okhttp3.internal.ws
|
package okhttp3.internal.ws
|
||||||
|
|
||||||
import okhttp3.internal.and
|
import okhttp3.internal.and
|
||||||
|
import okhttp3.internal.toHexString
|
||||||
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_FIN
|
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_FIN
|
||||||
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV1
|
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV1
|
||||||
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV2
|
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV2
|
||||||
@@ -39,7 +40,6 @@ import okio.Buffer
|
|||||||
import okio.BufferedSource
|
import okio.BufferedSource
|
||||||
import okio.ByteString
|
import okio.ByteString
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.lang.Integer.toHexString
|
|
||||||
import java.net.ProtocolException
|
import java.net.ProtocolException
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ internal class WebSocketReader(
|
|||||||
frameLength = source.readLong()
|
frameLength = source.readLong()
|
||||||
if (frameLength < 0) {
|
if (frameLength < 0) {
|
||||||
throw ProtocolException(
|
throw ProtocolException(
|
||||||
"Frame length 0x${java.lang.Long.toHexString(frameLength)} > 0x7FFFFFFFFFFFFFFF")
|
"Frame length 0x${frameLength.toHexString()} > 0x7FFFFFFFFFFFFFFF")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ internal class WebSocketReader(
|
|||||||
closed = true
|
closed = true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
throw ProtocolException("Unknown control opcode: " + toHexString(opcode))
|
throw ProtocolException("Unknown control opcode: " + opcode.toHexString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ internal class WebSocketReader(
|
|||||||
private fun readMessageFrame() {
|
private fun readMessageFrame() {
|
||||||
val opcode = this.opcode
|
val opcode = this.opcode
|
||||||
if (opcode != OPCODE_TEXT && opcode != OPCODE_BINARY) {
|
if (opcode != OPCODE_TEXT && opcode != OPCODE_BINARY) {
|
||||||
throw ProtocolException("Unknown opcode: ${toHexString(opcode)}")
|
throw ProtocolException("Unknown opcode: ${opcode.toHexString()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
readMessage()
|
readMessage()
|
||||||
@@ -260,7 +260,7 @@ internal class WebSocketReader(
|
|||||||
|
|
||||||
readUntilNonControlFrame()
|
readUntilNonControlFrame()
|
||||||
if (opcode != OPCODE_CONTINUATION) {
|
if (opcode != OPCODE_CONTINUATION) {
|
||||||
throw ProtocolException("Expected continuation opcode. Got: ${toHexString(opcode)}")
|
throw ProtocolException("Expected continuation opcode. Got: ${opcode.toHexString()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user